home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / diff_2_1.lha / diff-2.1 / texinfo.tex (.txt) < prev    next >
LaTeX Document  |  1993-01-29  |  125KB  |  3,050 lines

  1. %% TeX macros to handle texinfo files
  2. %   Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 Free Software Foundation, Inc.
  3. %This texinfo.tex file is free software; you can redistribute it and/or
  4. %modify it under the terms of the GNU General Public License as
  5. %published by the Free Software Foundation; either version 2, or (at
  6. %your option) any later version.
  7. %This texinfo.tex file is distributed in the hope that it will be
  8. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  9. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  10. %General Public License for more details.
  11. %You should have received a copy of the GNU General Public License
  12. %along with this texinfo.tex file; see the file COPYING.  If not, write
  13. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  14. %USA.
  15. %In other words, you are welcome to use, share and improve this program.
  16. %You are forbidden to forbid anyone else to use, share and improve
  17. %what you give them.   Help stamp out software-hoarding!
  18. \def\texinfoversion{2.94}
  19. \message{Loading texinfo package [Version \texinfoversion]:}
  20. \message{}
  21. % Print the version number if in a .fmt file.
  22. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  23. % Save some parts of plain tex whose names we will redefine.
  24. \let\ptexlbrace=\{
  25. \let\ptexrbrace=\}
  26. \let\ptexdots=\dots
  27. \let\ptexdot=\.
  28. \let\ptexstar=\*
  29. \let\ptexend=\end
  30. \let\ptexbullet=\bullet
  31. \let\ptexb=\b
  32. \let\ptexc=\c
  33. \let\ptexi=\i
  34. \let\ptext=\t
  35. \let\ptexl=\l
  36. \let\ptexL=\L
  37. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  38. \message{Basics,}
  39. \chardef\other=12
  40. % If this character appears in an error message or help string, it
  41. % starts a new line in the output.
  42. \newlinechar = `^^J
  43. % Ignore a token.
  44. \def\gobble#1{}
  45. \hyphenation{ap-pen-dix}
  46. \hyphenation{mini-buf-fer mini-buf-fers}
  47. \hyphenation{eshell}
  48. % Margin to add to right of even pages, to left of odd pages.
  49. \newdimen \bindingoffset  \bindingoffset=0pt
  50. \newdimen \normaloffset   \normaloffset=\hoffset
  51. \newdimen\pagewidth \newdimen\pageheight
  52. \pagewidth=\hsize \pageheight=\vsize
  53. % Sometimes it is convenient to have everything in the transcript file
  54. % and nothing on the terminal.  We don't just call \tracingall here,
  55. % since that produces some useless output on the terminal.
  56. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  57. \def\loggingall{\tracingcommands2 \tracingstats2 
  58.    \tracingpages1 \tracingoutput1 \tracinglostchars1 
  59.    \tracingmacros2 \tracingparagraphs1 \tracingrestores1 
  60.    \showboxbreadth\maxdimen\showboxdepth\maxdimen
  61. %---------------------Begin change-----------------------
  62. %%%% For @cropmarks command.
  63. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  64. \newdimen\cornerlong \newdimen\cornerthick
  65. \newdimen \topandbottommargin
  66. \newdimen \outerhsize \newdimen \outervsize
  67. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  68. \outerhsize=7in
  69. %\outervsize=9.5in
  70. % Alternative @smallbook page size is 9.25in
  71. \outervsize=9.25in
  72. \topandbottommargin=.75in
  73. %---------------------End change-----------------------
  74. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  75. % does insertions itself, but you have to call it yourself.
  76. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  77. \def\onepageout#1{\hoffset=\normaloffset
  78. \ifodd\pageno  \advance\hoffset by \bindingoffset
  79. \else \advance\hoffset by -\bindingoffset\fi
  80. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  81. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  82. {\let\hsize=\pagewidth \makefootline}}}%
  83. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  84. %%%% For @cropmarks command %%%%
  85. % Here is a modification of the main output routine for Near East Publications
  86. % This provides right-angle cropmarks at all four corners.
  87. % The contents of the page are centerlined into the cropmarks,
  88. % and any desired binding offset is added as an \hskip on either
  89. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  90. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  91. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  92.          \shipout
  93.          \vbox to \outervsize{\hsize=\outerhsize
  94.                  \vbox{\line{\ewtop\hfill\ewtop}}
  95.                  \nointerlineskip
  96.                  \line{\vbox{\moveleft\cornerthick\nstop}
  97.                        \hfill
  98.                        \vbox{\moveright\cornerthick\nstop}}
  99.                  \vskip \topandbottommargin
  100.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  101.             \vbox{
  102.             {\let\hsize=\pagewidth \makeheadline}
  103.             \pagebody{#1}
  104.             {\let\hsize=\pagewidth \makefootline}}
  105.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  106.          \vskip \topandbottommargin plus1fill minus1fill
  107.                  \boxmaxdepth\cornerthick
  108.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  109.                        \hfill
  110.                        \vbox{\moveright\cornerthick\nsbot}}
  111.                  \nointerlineskip
  112.                  \vbox{\line{\ewbot\hfill\ewbot}}
  113.   \advancepageno 
  114.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  115. % Do @cropmarks to get crop marks
  116. \def\cropmarks{\let\onepageout=\croppageout }
  117. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  118. {\catcode`\@ =11
  119. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  120. \dimen@=\dp#1 \unvbox#1
  121. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  122. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  123. % Here are the rules for the cropmarks.  Note that they are
  124. % offset so that the space between them is truly \outerhsize or \outervsize
  125. % (P. A. MacKay, 12 November, 1986)
  126. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  127. \def\nstop{\vbox
  128.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  129. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  130. \def\nsbot{\vbox
  131.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  132. % Parse an argument, then pass it to #1.  The argument is the rest of
  133. % the input line (except we remove a trailing comment).  #1 should be a
  134. % macro which expects an ordinary undelimited TeX argument.
  135. \def\parsearg#1{%
  136.   \let\next = #1%
  137.   \begingroup
  138.     \obeylines
  139.     \futurelet\temp\parseargx
  140. % If the next token is an obeyed space (from an @example environment or
  141. % the like), remove it and recurse.  Otherwise, we're done.
  142. \def\parseargx{%
  143.   \ifx\obeyedspace\temp
  144.     \expandafter\parseargdiscardspace
  145.   \else
  146.     \expandafter\parseargline
  147.   \fi
  148. % Remove a single space (as the delimiter token to the macro call).
  149. {\obeyspaces %
  150.  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  151. \def\obeyedspace{\ }
  152. {\obeylines %
  153.   \gdef\parseargline#1^^M{%
  154.     \endgroup % End of the group started in \parsearg.
  155.     %
  156.     % First remove any @c comment, then any @comment.
  157.     % Result of each macro is put in \toks0.
  158.     \argremovec #1\c\relax %
  159.     \expandafter\argremovecomment \the\toks0 \comment\relax %
  160.     %
  161.     % Call the caller's macro, saved as \next in \parsearg.
  162.     \expandafter\next\expandafter{\the\toks0}%
  163. % Since all \c{,omment} does is throw away the argument, we can let TeX
  164. % do that for us.  The \relax here is matched by the \relax in the call
  165. % in \parseargline; it could be more or less anything, its purpose is
  166. % just to delimit the argument to the \c.
  167. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  168. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  169. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  170. %    @end itemize  @c foo
  171. % will have two active spaces as part of the argument with the
  172. % `itemize'.  Here we remove all active spaces from #1, and assign the
  173. % result to \toks0.
  174. % This loses if there are any *other* active characters besides spaces
  175. % in the argument -- _ ^ +, for example -- since they get expanded.
  176. % Fortunately, Texinfo does not define any such commands.  (If it ever
  177. % does, the catcode of the characters in questionwill have to be changed
  178. % here.)  But this means we cannot call \removeactivespaces as part of
  179. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  180. % that \parsearg gets might well have any character at all in it.
  181. \def\removeactivespaces#1{%
  182.   \begingroup
  183.     \ignoreactivespaces
  184.     \edef\temp{#1}%
  185.     \global\toks0 = \expandafter{\temp}%
  186.   \endgroup
  187. % Change the active space to expand to nothing.
  188. \begingroup
  189.   \obeyspaces
  190.   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  191. \endgroup
  192. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  193. %% These are used to keep @begin/@end levels from running away
  194. %% Call \inENV within environments (after a \begingroup)
  195. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  196. \def\ENVcheck{%
  197. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  198. \endgroup\fi} % This is not perfect, but it should reduce lossage
  199. % @begin foo  is the same as @foo, for now.
  200. \newhelp\EMsimple{Type <Return> to continue.}
  201. \outer\def\begin{\parsearg\beginxxx}
  202. \def\beginxxx #1{%
  203. \expandafter\ifx\csname #1\endcsname\relax
  204. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  205. \csname #1\endcsname\fi}
  206. % @end foo executes the definition of \Efoo.
  207. \def\end{\parsearg\endxxx}
  208. \def\endxxx #1{%
  209.   \removeactivespaces{#1}%
  210.   \edef\endthing{\the\toks0}%
  211.   \expandafter\ifx\csname E\endthing\endcsname\relax
  212.     \expandafter\ifx\csname \endthing\endcsname\relax
  213.       % There's no \foo, i.e., no ``environment'' foo.
  214.       \errhelp = \EMsimple
  215.       \errmessage{Undefined command `@end \endthing'}%
  216.     \else
  217.       \unmatchedenderror\endthing
  218.     \fi
  219.   \else
  220.     % Everything's ok; the right environment has been started.
  221.     \csname E\endthing\endcsname
  222.   \fi
  223. % There is an environment #1, but it hasn't been started.  Give an error.
  224. \def\unmatchedenderror#1{%
  225.   \errhelp = \EMsimple
  226.   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
  227. % Define the control sequence \E#1 to give an unmatched @end error.
  228. \def\defineunmatchedend#1{%
  229.   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
  230. % Single-spacing is done by various environments.
  231. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  232. \def\singlespace{%
  233. {\advance \baselineskip by -\singlespaceskip
  234. \kern \baselineskip}%
  235. \baselineskip=\singlespaceskip
  236. %% Simple single-character @ commands
  237. % @@ prints an @
  238. % Kludge this until the fonts are right (grr).
  239. \def\@{{\tt \char '100}}
  240. % This is turned off because it was never documented
  241. % and you can use @w{...} around a quote to suppress ligatures.
  242. %% Define @` and @' to be the same as ` and '
  243. %% but suppressing ligatures.
  244. %\def\`{{`}}
  245. %\def\'{{'}}
  246. % Used to generate quoted braces.
  247. \def\mylbrace {{\tt \char '173}}
  248. \def\myrbrace {{\tt \char '175}}
  249. \let\{=\mylbrace
  250. \let\}=\myrbrace
  251. % @: forces normal size whitespace following.
  252. \def\:{\spacefactor=1000 }
  253. % @* forces a line break.
  254. \def\*{\hfil\break\hbox{}\ignorespaces}
  255. % @. is an end-of-sentence period.
  256. \def\.{.\spacefactor=3000 }
  257. % @w prevents a word break.  Without the \leavevmode, @w at the
  258. % beginning of a paragraph, when TeX is still in vertical mode, would
  259. % produce a whole line of output instead of starting the paragraph.
  260. \def\w#1{\leavevmode\hbox{#1}}
  261. % @group ... @end group forces ... to be all on one page, by enclosing
  262. % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  263. % to keep its height that of a normal line.  According to the rules for
  264. % \topskip (p.114 of the TeXbook), the glue inserted is
  265. % max (\topskip - \ht (first item), 0).  If that height is large,
  266. % therefore, no glue is inserted, and the space between the headline and
  267. % the text is small, which looks bad.
  268. \def\group{\begingroup
  269.   \ifnum\catcode13=\active \else
  270.     \errhelp = \groupinvalidhelp
  271.     \errmessage{@group invalid in context where filling is enabled}%
  272.   \fi
  273.   % The \vtop we start below produces a box with large depth; thus, TeX
  274.   % puts \baselineskip glue before it, and (when the next line of text
  275.   % is done) \lineskip glue after it.  (See p.82 of the TeXbook.)  But
  276.   % the next line of text also gets us \parskip glue.  Final result:
  277.   % space below is slightly more than space above.
  278.   \def\Egroup{%
  279.     \egroup           % End the \vtop.
  280.     \endgroup         % End the \group.
  281.   \vtop\bgroup
  282.     % We do @comment here in case we are called inside an environment,
  283.     % such as @example, where each end-of-line in the input causes an
  284.     % end-of-line in the output.  We don't want the end-of-line after
  285.     % the `@group' to put extra space in the output.  Since @group
  286.     % should appear on a line by itself (according to the Texinfo
  287.     % manual), we don't worry about eating any user text.
  288.     \comment
  289. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  290. % message, so this ends up printing `@group can only ...'.
  291. \newhelp\groupinvalidhelp{%
  292. group can only be used in environments such as @example,^^J%
  293. where each line of input produces a line of output.}
  294. % @need space-in-mils
  295. % forces a page break if there is not space-in-mils remaining.
  296. \newdimen\mil  \mil=0.001in
  297. \def\need{\parsearg\needx}
  298. % Old definition--didn't work.
  299. %\def\needx #1{\par %
  300. %% This method tries to make TeX break the page naturally
  301. %% if the depth of the box does not fit.
  302. %{\baselineskip=0pt%
  303. %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  304. %\prevdepth=-1000pt
  305. \def\needx#1{%
  306.   % Go into vertical mode, so we don't make a big box in the middle of a
  307.   % paragraph.
  308.   \par
  309.   % Don't add any leading before our big empty box, but allow a page
  310.   % break, since the best break might be right here.
  311.   \allowbreak
  312.   \nointerlineskip
  313.   \vtop to #1\mil{\vfil}%
  314.   % TeX does not even consider page breaks if a penalty added to the
  315.   % main vertical list is 10000 or more.  But in order to see if the
  316.   % empty box we just added fits on the page, we must make it consider
  317.   % page breaks.  On the other hand, we don't want to actually break the
  318.   % page after the empty box.  So we use a penalty of 9999.
  319.   % There is an extremely small chance that TeX will actually break the
  320.   % page at this \penalty, if there are no other feasible breakpoints in
  321.   % sight.  (If the user is using lots of big @group commands, which
  322.   % almost-but-not-quite fill up a page, TeX will have a hard time doing
  323.   % good page breaking, for example.)  However, I could not construct an
  324.   % example where a page broke at this \penalty; if it happens in a real
  325.   % document, then we can reconsider our strategy.
  326.   \penalty9999
  327.   % Back up by the size of the box, whether we did a page break or not.
  328.   \kern -#1\mil
  329.   % Do not allow a page break right after this kern.
  330.   \nobreak
  331. % @br   forces paragraph break
  332. \let\br = \par
  333. % @dots{}  output some dots
  334. \def\dots{$\ldots$}
  335. % @page    forces the start of a new page
  336. \def\page{\par\vfill\supereject}
  337. % @exdent text....
  338. % outputs text on separate line in roman font, starting at standard page margin
  339. % This records the amount of indent in the innermost environment.
  340. % That's how much \exdent should take out.
  341. \newskip\exdentamount
  342. % This defn is used inside fill environments such as @defun.
  343. \def\exdent{\parsearg\exdentyyy}
  344. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  345. % This defn is used inside nofill environments such as @example.
  346. \def\nofillexdent{\parsearg\nofillexdentyyy}
  347. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  348. \leftline{\hskip\leftskip{\rm#1}}}}
  349. %\hbox{{\rm#1}}\hfil\break}}
  350. % @include file    insert text of that file as input.
  351. \def\include{\parsearg\includezzz}
  352. \def\includezzz #1{\def\thisfile{#1}\input #1
  353. \def\thisfile{}}
  354. \def\thisfile{}
  355. % @center line   outputs that line, centered
  356. \def\center{\parsearg\centerzzz}
  357. \def\centerzzz #1{{\advance\hsize by -\leftskip
  358. \advance\hsize by -\rightskip
  359. \centerline{#1}}}
  360. % @sp n   outputs n lines of vertical space
  361. \def\sp{\parsearg\spxxx}
  362. \def\spxxx #1{\par \vskip #1\baselineskip}
  363. % @comment ...line which is ignored...
  364. % @c is the same as @comment
  365. % @ignore ... @end ignore  is another way to write a comment
  366. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  367. \parsearg \commentxxx}
  368. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  369. \let\c=\comment
  370. % Prevent errors for section commands.
  371. % Used in @ignore and in failing conditionals.
  372. \def\ignoresections{%
  373. \let\chapter=\relax
  374. \let\unnumbered=\relax
  375. \let\top=\relax
  376. \let\unnumberedsec=\relax
  377. \let\unnumberedsection=\relax
  378. \let\unnumberedsubsec=\relax
  379. \let\unnumberedsubsection=\relax
  380. \let\unnumberedsubsubsec=\relax
  381. \let\unnumberedsubsubsection=\relax
  382. \let\section=\relax
  383. \let\subsec=\relax
  384. \let\subsubsec=\relax
  385. \let\subsection=\relax
  386. \let\subsubsection=\relax
  387. \let\appendix=\relax
  388. \let\appendixsec=\relax
  389. \let\appendixsection=\relax
  390. \let\appendixsubsec=\relax
  391. \let\appendixsubsection=\relax
  392. \let\appendixsubsubsec=\relax
  393. \let\appendixsubsubsection=\relax
  394. \let\contents=\relax
  395. \let\smallbook=\relax
  396. \let\titlepage=\relax
  397. % Used in nested conditionals, where we have to parse the Texinfo source
  398. % and so want to turn off most commands, in case they are used
  399. % incorrectly.  
  400. \def\ignoremorecommands{%
  401.   \let\defcv = \relax
  402.   \let\deffn = \relax
  403.   \let\deffnx = \relax
  404.   \let\defindex = \relax
  405.   \let\defivar = \relax
  406.   \let\defmac = \relax
  407.   \let\defmethod = \relax
  408.   \let\defop = \relax
  409.   \let\defopt = \relax
  410.   \let\defspec = \relax
  411.   \let\deftp = \relax
  412.   \let\deftypefn = \relax
  413.   \let\deftypefun = \relax
  414.   \let\deftypevar = \relax
  415.   \let\deftypevr = \relax
  416.   \let\defun = \relax
  417.   \let\defvar = \relax
  418.   \let\defvr = \relax
  419.   \let\ref = \relax
  420.   \let\xref = \relax
  421.   \let\pxref = \relax
  422.   \let\settitle = \relax
  423. % Ignore @ignore ... @end ignore.
  424. \def\ignore{\doignore{ignore}}
  425. % Also ignore @ifinfo, @menu, and @direntry text.
  426. \def\ifinfo{\doignore{ifinfo}}
  427. \def\menu{\doignore{menu}}
  428. \def\direntry{\doignore{direntry}}
  429. % Ignore text until a line `@end #1'.
  430. \def\doignore#1{\begingroup
  431.   % Don't complain about control sequences we have declared \outer.
  432.   \ignoresections
  433.   % Define a command to swallow text until we reach `@end #1'.
  434.   \long\def\doignoretext##1\end #1{\enddoignore}%
  435.   % Make sure that spaces turn into tokens that match what \doignoretext wants.
  436.   \catcode32 = 10
  437.   % And now expand that command.
  438.   \doignoretext
  439. % What we do to finish off ignored text.
  440. \def\enddoignore{\endgroup\ignorespaces}%
  441. % Ignore text, except that we keep track of conditional commands for
  442. % purposes of nesting, up to an `@end #1' command.
  443. \def\nestedignore#1{%
  444.   % We must actually expand the ignored text to look for the @end
  445.   % command, so that nested ignore constructs work.  Thus, we put the
  446.   % text into a \vbox and then do nothing with the result.  To minimize
  447.   % the change of memory overflow, we follow the approach outlined on
  448.   % page 401 of the TeXbook: make the current font be a dummy font.
  449.   \setbox0 = \vbox\bgroup
  450.     % Don't complain about control sequences we have declared \outer.
  451.     \ignoresections
  452.     %
  453.     % Define `@end #1' to end the box, which will in turn undefine the
  454.     % @end command again.
  455.     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
  456.     %
  457.     % We are going to be parsing Texinfo commands.  Most cause no
  458.     % trouble when they are used incorrectly, but some commands do
  459.     % complicated argument parsing or otherwise get confused, so we
  460.     % undefine them.
  461.     %
  462.     % We can't do anything about stray @-signs, unfortunately;
  463.     % they'll produce `undefined control sequence' errors.
  464.     \ignoremorecommands
  465.     % 
  466.     % Set the current font to be \nullfont, a TeX primitive, and define
  467.     % all the font commands to also use \nullfont.  We don't use
  468.     % dummy.tfm, as suggested in the TeXbook, because not all sites
  469.     % might have that installed.  Therefore, math mode will still
  470.     % produce output, but that should be an extremely small amount of
  471.     % stuff compared to the main input.
  472.     \nullfont
  473.     \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
  474.     \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
  475.     \let\tensf = \nullfont
  476.     %
  477.     % Don't complain when characters are missing from the fonts.
  478.     \tracinglostchars = 0
  479.     %
  480.     % Don't bother to do space factor calculations.
  481.     \frenchspacing
  482.     %
  483.     % Don't report underfull hboxes.
  484.     \hbadness = 10000
  485.     %
  486.     % Do minimal line-breaking.
  487.     \pretolerance = 10000
  488. % @set VAR sets the variable VAR to an empty value.
  489. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  490. % Since we want to separate VAR from REST-OF-LINE (which might be
  491. % empty), we can't just use \parsearg; we have to insert a space of our
  492. % own to delimit the rest of the line, and then take it out again if we
  493. % didn't need it.
  494. \def\set{\parsearg\setxxx}
  495. \def\setxxx#1{\setyyy#1 \endsetyyy}
  496. \def\setyyy#1 #2\endsetyyy{%
  497.   \def\temp{#2}%
  498.   \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
  499.   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
  500.   \fi
  501. \def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}}
  502. % @clear VAR clears (i.e., unsets) the variable VAR.
  503. \def\clear{\parsearg\clearxxx}
  504. \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
  505. % @value{foo} gets the text saved in variable foo.
  506. \def\value#1{\expandafter
  507.         \ifx\csname SET#1\endcsname\relax
  508.             {\{No value for ``#1''\}}
  509.         \else \csname SET#1\endcsname \fi}
  510. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  511. % with @set.
  512. \def\ifset{\parsearg\ifsetxxx}
  513. \def\ifsetxxx #1{%
  514.   \expandafter\ifx\csname SET#1\endcsname\relax
  515.     \expandafter\ifsetfail
  516.   \else
  517.     \expandafter\ifsetsucceed
  518.   \fi
  519. \def\ifsetsucceed{\conditionalsucceed{ifset}}
  520. \def\ifsetfail{\nestedignore{ifset}}
  521. \defineunmatchedend{ifset}
  522. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  523. % defined with @set, or has been undefined with @clear.
  524. \def\ifclear{\parsearg\ifclearxxx}
  525. \def\ifclearxxx #1{%
  526.   \expandafter\ifx\csname SET#1\endcsname\relax
  527.     \expandafter\ifclearsucceed
  528.   \else
  529.     \expandafter\ifclearfail
  530.   \fi
  531. \def\ifclearsucceed{\conditionalsucceed{ifclear}}
  532. \def\ifclearfail{\nestedignore{ifclear}}
  533. \defineunmatchedend{ifclear}
  534. % @iftex always succeeds; we read the text following, through @end
  535. % iftex).  But `@end iftex' should be valid only after an @iftex.
  536. \def\iftex{\conditionalsucceed{iftex}}
  537. \defineunmatchedend{iftex}
  538. % We can't just want to start a group at @iftex (for example) and end it
  539. % at @end iftex, since then @set commands inside the conditional have no
  540. % effect (they'd get reverted at the end of the group).  So we must
  541. % define \Eiftex to redefine itself to be its previous value.  (We can't
  542. % just define it to fail again with an ``unmatched end'' error, since
  543. % the @ifset might be nested.)
  544. \def\conditionalsucceed#1{%
  545.   \edef\temp{%
  546.     % Remember the current value of \E#1.
  547.     \let\nece{prevE#1} = \nece{E#1}%
  548.     %
  549.     % At the `@end #1', redefine \E#1 to be its previous value.
  550.     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
  551.   \temp
  552. % We need to expand lots of \csname's, but we don't want to expand the
  553. % control sequences after we've constructed them.
  554. \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
  555. % @asis just yields its argument.  Used with @table, for example.
  556. \def\asis#1{#1}
  557. % @math means output in math mode.
  558. % We don't use $'s directly in the definition of \math because control
  559. % sequences like \math are expanded when the toc file is written.  Then,
  560. % we read the toc file back, the $'s will be normal characters (as they
  561. % should be, according to the definition of Texinfo).  So we must use a
  562. % control sequence to switch into and out of math mode.
  563. % This isn't quite enough for @math to work properly in indices, but it
  564. % seems unlikely it will ever be needed there.
  565. \let\implicitmath = $
  566. \def\math#1{\implicitmath #1\implicitmath}
  567. % @bullet and @minus need the same treatment as @math, just above.
  568. \def\bullet{\implicitmath\ptexbullet\implicitmath}
  569. \def\minus{\implicitmath-\implicitmath}
  570. \def\node{\ENVcheck\parsearg\nodezzz}
  571. \def\nodezzz#1{\nodexxx [#1,]}
  572. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  573. \let\lastnode=\relax
  574. \def\donoderef{\ifx\lastnode\relax\else
  575. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  576. \let\lastnode=\relax}
  577. \def\unnumbnoderef{\ifx\lastnode\relax\else
  578. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  579. \let\lastnode=\relax}
  580. \def\appendixnoderef{\ifx\lastnode\relax\else
  581. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  582. \let\lastnode=\relax}
  583. \let\refill=\relax
  584. % @setfilename is done at the beginning of every texinfo file.
  585. % So open here the files we need to have open while reading the input.
  586. % This makes it possible to make a .fmt file for texinfo.
  587. \def\setfilename{%
  588.    \readauxfile
  589.    \opencontents
  590.    \openindices
  591.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  592.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  593.    \comment % Ignore the actual filename.
  594. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  595. \def\inforef #1{\inforefzzz #1,,,,**}
  596. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\ignorespaces #3{}},
  597.   node \samp{\ignorespaces#1{}}}
  598. \message{fonts,}
  599. % Font-change commands.
  600. % Texinfo supports the sans serif font style, which plain TeX does not.
  601. % So we set up a \sf analogous to plain's \rm, etc.
  602. \newfam\sffam
  603. \def\sf{\fam=\sffam \tensf}
  604. \let\li = \sf % Sometimes we call it \li, not \sf.
  605. %% Try out Computer Modern fonts at \magstephalf
  606. \let\mainmagstep=\magstephalf
  607. \ifx\bigger\relax
  608. \let\mainmagstep=\magstep1
  609. \font\textrm=cmr12
  610. \font\texttt=cmtt12
  611. \else
  612. \font\textrm=cmr10 scaled \mainmagstep
  613. \font\texttt=cmtt10 scaled \mainmagstep
  614. % Instead of cmb10, you many want to use cmbx10.
  615. % cmbx10 is a prettier font on its own, but cmb10
  616. % looks better when embedded in a line with cmr10.
  617. \font\textbf=cmb10 scaled \mainmagstep 
  618. \font\textit=cmti10 scaled \mainmagstep
  619. \font\textsl=cmsl10 scaled \mainmagstep
  620. \font\textsf=cmss10 scaled \mainmagstep
  621. \font\textsc=cmcsc10 scaled \mainmagstep
  622. \font\texti=cmmi10 scaled \mainmagstep
  623. \font\textsy=cmsy10 scaled \mainmagstep
  624. % A few fonts for @defun, etc.
  625. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  626. \font\deftt=cmtt10 scaled \magstep1
  627. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  628. % Fonts for indices and small examples.
  629. % We actually use the slanted font rather than the italic, 
  630. % because texinfo normally uses the slanted fonts for that.
  631. % Do not make many font distinctions in general in the index, since they
  632. % aren't very useful.
  633. \font\ninett=cmtt9
  634. \font\indrm=cmr9
  635. \font\indit=cmsl9
  636. \let\indsl=\indit
  637. \let\indtt=\ninett
  638. \let\indsf=\indrm
  639. \let\indbf=\indrm
  640. \let\indsc=\indrm
  641. \font\indi=cmmi9
  642. \font\indsy=cmsy9
  643. % Fonts for headings
  644. \font\chaprm=cmbx12 scaled \magstep2
  645. \font\chapit=cmti12 scaled \magstep2
  646. \font\chapsl=cmsl12 scaled \magstep2
  647. \font\chaptt=cmtt12 scaled \magstep2
  648. \font\chapsf=cmss12 scaled \magstep2
  649. \let\chapbf=\chaprm
  650. \font\chapsc=cmcsc10 scaled\magstep3
  651. \font\chapi=cmmi12 scaled \magstep2
  652. \font\chapsy=cmsy10 scaled \magstep3
  653. \font\secrm=cmbx12 scaled \magstep1
  654. \font\secit=cmti12 scaled \magstep1
  655. \font\secsl=cmsl12 scaled \magstep1
  656. \font\sectt=cmtt12 scaled \magstep1
  657. \font\secsf=cmss12 scaled \magstep1
  658. \font\secbf=cmbx12 scaled \magstep1
  659. \font\secsc=cmcsc10 scaled\magstep2
  660. \font\seci=cmmi12 scaled \magstep1
  661. \font\secsy=cmsy10 scaled \magstep2
  662. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
  663. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  664. % \font\ssecsl=cmsl10 scaled \magstep1
  665. % \font\ssectt=cmtt10 scaled \magstep1
  666. % \font\ssecsf=cmss10 scaled \magstep1
  667. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  668. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  669. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  670. %\font\ssectt=cmtt10 scaled 1315
  671. %\font\ssecsf=cmss10 scaled 1315
  672. %\let\ssecbf=\ssecrm
  673. \font\ssecrm=cmbx12 scaled \magstephalf
  674. \font\ssecit=cmti12 scaled \magstephalf
  675. \font\ssecsl=cmsl12 scaled \magstephalf
  676. \font\ssectt=cmtt12 scaled \magstephalf
  677. \font\ssecsf=cmss12 scaled \magstephalf
  678. \font\ssecbf=cmbx12 scaled \magstephalf
  679. \font\ssecsc=cmcsc10 scaled \magstep1 
  680. \font\sseci=cmmi12 scaled \magstephalf
  681. \font\ssecsy=cmsy10 scaled \magstep1
  682. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  683. % but that is not a standard magnification.
  684. % Fonts for title page:
  685. \font\titlerm = cmbx12 scaled \magstep3
  686. \let\authorrm = \secrm
  687. % In order for the font changes to affect most math symbols and letters,
  688. % we have to define the \textfont of the standard families.  Since
  689. % texinfo doesn't allow for producing subscripts and superscripts, we
  690. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  691. % also require loading a lot more fonts).
  692. \def\resetmathfonts{%
  693.   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  694.   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  695.   \textfont\ttfam = \tentt \textfont\sffam = \tensf
  696. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  697. % of just \STYLE.  We do this so that font changes will continue to work
  698. % in math mode, where it is the current \fam that is relevant in most
  699. % cases, not the current.  Plain TeX does, for example,
  700. % \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
  701. % to redefine \bf itself.  
  702. \def\textfonts{%
  703.   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  704.   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  705.   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  706.   \resetmathfonts}
  707. \def\chapfonts{%
  708.   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl 
  709.   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  710.   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  711.   \resetmathfonts}
  712. \def\secfonts{%
  713.   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  714.   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  715.   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  716.   \resetmathfonts}
  717. \def\subsecfonts{%
  718.   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  719.   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  720.   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  721.   \resetmathfonts}
  722. \def\indexfonts{%
  723.   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  724.   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  725.   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
  726.   \resetmathfonts}
  727. % Set up the default fonts, so we can use them for creating boxes.
  728. \textfonts
  729. % Count depth in font-changes, for error checks
  730. \newcount\fontdepth \fontdepth=0
  731. % Fonts for short table of contents.
  732. \font\shortcontrm=cmr12
  733. \font\shortcontbf=cmbx12
  734. \font\shortcontsl=cmsl12
  735. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  736. %% serif) and @ii for TeX italic
  737. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  738. % unless the following character is such as not to need one.
  739. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  740. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  741. \let\i=\smartitalic
  742. \let\var=\smartitalic
  743. \let\dfn=\smartitalic
  744. \let\emph=\smartitalic
  745. \let\cite=\smartitalic
  746. \def\b#1{{\bf #1}}
  747. \let\strong=\b
  748. % We can't just use \exhyphenpenalty, because that only has effect at
  749. % the end of a paragraph.  Restore normal hyphenation at the end of the
  750. % group within which \nohyphenation is presumably called.
  751. \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
  752. \def\restorehyphenation{\hyphenchar\font = `- }
  753. \def\t#1{%
  754.   {\tt \nohyphenation \rawbackslash \frenchspacing #1}%
  755.   \null
  756. \let\ttfont = \t
  757. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  758. \def\samp #1{`\tclose{#1}'\null}
  759. \def\key #1{{\tt \nohyphenation \uppercase{#1}}\null}
  760. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  761. \let\file=\samp
  762. % @code is a modification of @t,
  763. % which makes spaces the same size as normal in the surrounding text.
  764. \def\tclose#1{%
  765.     % Change normal interword space to be same as for the current font.
  766.     \spaceskip = \fontdimen2\font
  767.     %
  768.     % Switch to typewriter.
  769.     \tt
  770.     %
  771.     % But `\ ' produces the large typewriter interword space.
  772.     \def\ {{\spaceskip = 0pt{} }}%
  773.     %
  774.     % Turn off hyphenation.
  775.     \nohyphenation
  776.     % 
  777.     \rawbackslash
  778.     \frenchspacing
  779.     #1%
  780.   \null
  781. \let\code=\tclose
  782. %\let\exp=\tclose  %Was temporary
  783. % @kbd is like @code, except that if the argument is just one @key command, 
  784. % then @kbd has no effect.
  785. \def\xkey{\key}
  786. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  787. \ifx\one\xkey\ifx\threex\three \key{#2}%
  788. \else\tclose{\look}\fi
  789. \else\tclose{\look}\fi}
  790. % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  791. % argument is to make the input look right: @dmn{pt} instead of
  792. % @dmn{}pt.
  793. \def\dmn#1{\thinspace #1}
  794. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  795. \def\l#1{{\li #1}\null}        % 
  796. \def\r#1{{\rm #1}}        % roman font
  797. % Use of \lowercase was suggested.
  798. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  799. \def\ii#1{{\it #1}}        % italic font
  800. \message{page headings,}
  801. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  802. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  803. % First the title page.  Must do @settitle before @titlepage.
  804. \def\titlefont#1{{\titlerm #1}}
  805. \newtoks\realeverypar
  806. \newif\ifseenauthor
  807. \newif\iffinishedtitlepage
  808. \def\shorttitlepage{\parsearg\shorttitlepagezzz}
  809. \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
  810.     \endgroup\page\hbox{}\page}
  811. \def\titlepage{\begingroup \parindent=0pt \textfonts
  812.    \let\subtitlerm=\tenrm
  813. % I deinstalled the following change because \cmr12 is undefined.
  814. % This change was not in the ChangeLog anyway.  --rms.
  815. %   \let\subtitlerm=\cmr12
  816.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  817.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  818.    % Leave some space at the very top of the page.
  819.    \vglue\titlepagetopglue
  820.    % Now you can print the title using @title.
  821.    \def\title{\parsearg\titlezzz}%
  822.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  823.             % print a rule at the page bottom also.
  824.             \finishedtitlepagefalse
  825.             \vskip4pt \hrule height 4pt \vskip4pt}%
  826.    % No rule at page bottom unless we print one at the top with @title.
  827.    \finishedtitlepagetrue
  828.    % Now you can put text using @subtitle.
  829.    \def\subtitle{\parsearg\subtitlezzz}%
  830.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  831.    % @author should come last, but may come many times.
  832.    \def\author{\parsearg\authorzzz}%
  833.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  834.       {\authorfont \leftline{##1}}}%
  835.    %  
  836.    % Most title ``pages'' are actually two pages long, with space
  837.    % at the top of the second.  We don't want the ragged left on the second.
  838.    \let\oldpage = \page
  839.    \def\page{%
  840.       \iffinishedtitlepage\else
  841.      \finishtitlepage
  842.       \fi
  843.       \oldpage
  844.       \let\page = \oldpage
  845.       \hbox{}}%
  846. %   \def\page{\oldpage \hbox{}}
  847. \def\Etitlepage{%
  848.    \iffinishedtitlepage\else
  849.       \finishtitlepage
  850.    \fi
  851.    % It is important to do the page break before ending the group,
  852.    % because the headline and footline are only empty inside the group.
  853.    % If we use the new definition of \page, we always get a blank page
  854.    % after the title page, which we certainly don't want.
  855.    \oldpage
  856.    \endgroup
  857.    \HEADINGSon
  858. \def\finishtitlepage{%
  859.    \vskip4pt \hrule height 2pt
  860.    \vskip\titlepagebottomglue
  861.    \finishedtitlepagetrue
  862. %%% Set up page headings and footings.
  863. \let\thispage=\folio
  864. \newtoks \evenheadline    % Token sequence for heading line of even pages
  865. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  866. \newtoks \evenfootline    % Token sequence for footing line of even pages
  867. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  868. % Now make Tex use those variables
  869. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  870.                             \else \the\evenheadline \fi}}
  871. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  872.                             \else \the\evenfootline \fi}\HEADINGShook}
  873. \let\HEADINGShook=\relax
  874. % Commands to set those variables.
  875. % For example, this is what  @headings on  does
  876. % @evenheading @thistitle|@thispage|@thischapter
  877. % @oddheading @thischapter|@thispage|@thistitle
  878. % @evenfooting @thisfile||
  879. % @oddfooting ||@thisfile
  880. \def\evenheading{\parsearg\evenheadingxxx}
  881. \def\oddheading{\parsearg\oddheadingxxx}
  882. \def\everyheading{\parsearg\everyheadingxxx}
  883. \def\evenfooting{\parsearg\evenfootingxxx}
  884. \def\oddfooting{\parsearg\oddfootingxxx}
  885. \def\everyfooting{\parsearg\everyfootingxxx}
  886. {\catcode`\@=0 %
  887. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  888. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  889. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  890. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  891. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  892. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  893. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  894. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  895. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  896. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  897. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  898. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  899. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  900. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  901. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  902. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  903. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  904. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  905. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  906. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  907. }% unbind the catcode of @.
  908. % @headings double    turns headings on for double-sided printing.
  909. % @headings single    turns headings on for single-sided printing.
  910. % @headings off        turns them off.
  911. % @headings on        same as @headings double, retained for compatibility.
  912. % @headings after    turns on double-sided headings after this page.
  913. % @headings doubleafter    turns on double-sided headings after this page.
  914. % @headings singleafter turns on single-sided headings after this page.
  915. % By default, they are off.
  916. \def\headings #1 {\csname HEADINGS#1\endcsname}
  917. \def\HEADINGSoff{
  918. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  919. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  920. \HEADINGSoff
  921. % When we turn headings on, set the page number to 1.
  922. % For double-sided printing, put current file name in lower left corner,
  923. % chapter name on inside top of right hand pages, document
  924. % title on inside top of left hand pages, and page numbers on outside top
  925. % edge of all pages.
  926. \def\HEADINGSdouble{
  927. %\pagealignmacro
  928. \global\pageno=1
  929. \global\evenfootline={\hfil}
  930. \global\oddfootline={\hfil}
  931. \global\evenheadline={\line{\folio\hfil\thistitle}}
  932. \global\oddheadline={\line{\thischapter\hfil\folio}}
  933. % For single-sided printing, chapter title goes across top left of page,
  934. % page number on top right.
  935. \def\HEADINGSsingle{
  936. %\pagealignmacro
  937. \global\pageno=1
  938. \global\evenfootline={\hfil}
  939. \global\oddfootline={\hfil}
  940. \global\evenheadline={\line{\thischapter\hfil\folio}}
  941. \global\oddheadline={\line{\thischapter\hfil\folio}}
  942. \def\HEADINGSon{\HEADINGSdouble}
  943. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  944. \let\HEADINGSdoubleafter=\HEADINGSafter
  945. \def\HEADINGSdoublex{%
  946. \global\evenfootline={\hfil}
  947. \global\oddfootline={\hfil}
  948. \global\evenheadline={\line{\folio\hfil\thistitle}}
  949. \global\oddheadline={\line{\thischapter\hfil\folio}}
  950. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  951. \def\HEADINGSsinglex{%
  952. \global\evenfootline={\hfil}
  953. \global\oddfootline={\hfil}
  954. \global\evenheadline={\line{\thischapter\hfil\folio}}
  955. \global\oddheadline={\line{\thischapter\hfil\folio}}
  956. % Subroutines used in generating headings
  957. % Produces Day Month Year style of output.
  958. \def\today{\number\day\space
  959. \ifcase\month\or
  960. January\or February\or March\or April\or May\or June\or
  961. July\or August\or September\or October\or November\or December\fi
  962. \space\number\year}
  963. % Use this if you want the Month Day, Year style of output.
  964. %\def\today{\ifcase\month\or
  965. %January\or February\or March\or April\or May\or June\or
  966. %July\or August\or September\or October\or November\or December\fi
  967. %\space\number\day, \number\year}
  968. % @settitle line...  specifies the title of the document, for headings
  969. % It generates no output of its own
  970. \def\thistitle{No Title}
  971. \def\settitle{\parsearg\settitlezzz}
  972. \def\settitlezzz #1{\gdef\thistitle{#1}}
  973. \message{tables,}
  974. % @tabs -- simple alignment
  975. % These don't work.  For one thing, \+ is defined as outer.
  976. % So these macros cannot even be defined.
  977. %\def\tabs{\parsearg\tabszzz}
  978. %\def\tabszzz #1{\settabs\+#1\cr}
  979. %\def\tabline{\parsearg\tablinezzz}
  980. %\def\tablinezzz #1{\+#1\cr}
  981. %\def\&{&}
  982. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  983. % default indentation of table text
  984. \newdimen\tableindent \tableindent=.8in
  985. % default indentation of @itemize and @enumerate text
  986. \newdimen\itemindent  \itemindent=.3in
  987. % margin between end of table item and start of table text.
  988. \newdimen\itemmargin  \itemmargin=.1in
  989. % used internally for \itemindent minus \itemmargin
  990. \newdimen\itemmax
  991. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  992. % these defs.
  993. % They also define \itemindex
  994. % to index the item name in whatever manner is desired (perhaps none).
  995. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  996. \def\internalBitemx{\par \parsearg\itemzzz}
  997. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  998. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  999. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  1000. \def\internalBkitemx{\par \parsearg\kitemzzz}
  1001. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  1002.                  \itemzzz {#1}}
  1003. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  1004.                  \itemzzz {#1}}
  1005. \def\itemzzz #1{\begingroup %
  1006.   \advance\hsize by -\rightskip
  1007.   \advance\hsize by -\tableindent
  1008.   \setbox0=\hbox{\itemfont{#1}}%
  1009.   \itemindex{#1}%
  1010.   \nobreak % This prevents a break before @itemx.
  1011.   % Be sure we are not still in the middle of a paragraph.
  1012.   \parskip=0in
  1013.   \par
  1014.   % If the item text does not fit in the space we have, put it on a line
  1015.   % by itself, and do not allow a page break either before or after that
  1016.   % line.  We do not start a paragraph here because then if the next
  1017.   % command is, e.g., @kindex, the whatsit would get put into the
  1018.   % horizontal list on a line by itself, resulting in extra blank space.
  1019.   \ifdim \wd0>\itemmax
  1020.     \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0
  1021.     \nobreak
  1022.   \else
  1023.     % The item text fits into the space.  Start a paragraph, so that the
  1024.     % following text (if any) will end up on the same line.  Since that
  1025.     % text will be indented by \tableindent, we make the item text be in
  1026.     % a zero-width box.
  1027.     \noindent
  1028.     \rlap{\hskip -\tableindent\box0}%
  1029.     \ignorespaces
  1030.   \fi
  1031.   \endgroup
  1032. \def\item{\errmessage{@item while not in a table}}
  1033. \def\itemx{\errmessage{@itemx while not in a table}}
  1034. \def\kitem{\errmessage{@kitem while not in a table}}
  1035. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1036. \def\xitem{\errmessage{@xitem while not in a table}}
  1037. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1038. %% Contains a kludge to get @end[description] to work
  1039. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1040. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1041. {\obeylines\obeyspaces%
  1042. \gdef\tablex #1^^M{%
  1043. \tabley\dontindex#1        \endtabley}}
  1044. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1045. {\obeylines\obeyspaces%
  1046. \gdef\ftablex #1^^M{%
  1047. \tabley\fnitemindex#1        \endtabley
  1048. \def\Eftable{\endgraf\endgroup\afterenvbreak}%
  1049. \let\Etable=\relax}}
  1050. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1051. {\obeylines\obeyspaces%
  1052. \gdef\vtablex #1^^M{%
  1053. \tabley\vritemindex#1        \endtabley
  1054. \def\Evtable{\endgraf\endgroup\afterenvbreak}%
  1055. \let\Etable=\relax}}
  1056. \def\dontindex #1{}
  1057. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1058. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1059. {\obeyspaces %
  1060. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1061. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1062. \def\tablez #1#2#3#4#5#6{%
  1063. \aboveenvbreak %
  1064. \begingroup %
  1065. \def\Edescription{\Etable}% Neccessary kludge.
  1066. \let\itemindex=#1%
  1067. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1068. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1069. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1070. \def\itemfont{#2}%
  1071. \itemmax=\tableindent %
  1072. \advance \itemmax by -\itemmargin %
  1073. \advance \leftskip by \tableindent %
  1074. \exdentamount=\tableindent
  1075. \parindent = 0pt
  1076. \parskip = \smallskipamount
  1077. \ifdim \parskip=0pt \parskip=2pt \fi%
  1078. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  1079. \let\item = \internalBitem %
  1080. \let\itemx = \internalBitemx %
  1081. \let\kitem = \internalBkitem %
  1082. \let\kitemx = \internalBkitemx %
  1083. \let\xitem = \internalBxitem %
  1084. \let\xitemx = \internalBxitemx %
  1085. % This is the counter used by @enumerate, which is really @itemize
  1086. \newcount \itemno
  1087. \def\itemize{\parsearg\itemizezzz}
  1088. \def\itemizezzz #1{%
  1089.   \begingroup % ended by the @end itemsize
  1090.   \itemizey {#1}{\Eitemize}
  1091. \def\itemizey #1#2{%
  1092. \aboveenvbreak %
  1093. \itemmax=\itemindent %
  1094. \advance \itemmax by -\itemmargin %
  1095. \advance \leftskip by \itemindent %
  1096. \exdentamount=\itemindent
  1097. \parindent = 0pt %
  1098. \parskip = \smallskipamount %
  1099. \ifdim \parskip=0pt \parskip=2pt \fi%
  1100. \def#2{\endgraf\endgroup\afterenvbreak}%
  1101. \def\itemcontents{#1}%
  1102. \let\item=\itemizeitem}
  1103. % Set sfcode to normal for the chars that usually have another value.
  1104. % These are `.?!:;,'
  1105. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1106.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1107. % \splitoff TOKENS\endmark defines \first to be the first token in
  1108. % TOKENS, and \rest to be the remainder.
  1109. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1110. % Allow an optional argument of an uppercase letter, lowercase letter,
  1111. % or number, to specify the first label in the enumerated list.  No
  1112. % argument is the same as `1'.
  1113. \def\enumerate{\parsearg\enumeratezzz}
  1114. \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
  1115. \def\enumeratey #1 #2\endenumeratey{%
  1116.   \begingroup % ended by the @end enumerate
  1117.   % If we were given no argument, pretend we were given `1'.
  1118.   \def\thearg{#1}%
  1119.   \ifx\thearg\empty \def\thearg{1}\fi
  1120.   % Detect if the argument is a single token.  If so, it might be a
  1121.   % letter.  Otherwise, the only valid thing it can be is a number.
  1122.   % (We will always have one token, because of the test we just made.
  1123.   % This is a good thing, since \splitoff doesn't work given nothing at
  1124.   % all -- the first parameter is undelimited.)
  1125.   \expandafter\splitoff\thearg\endmark
  1126.   \ifx\rest\empty
  1127.     % Only one token in the argument.  It could still be anything.
  1128.     % A ``lowercase letter'' is one whose \lccode is nonzero.
  1129.     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1130.     %   not equal to itself.
  1131.     % Otherwise, we assume it's a number.
  1132.     % 
  1133.     % We need the \relax at the end of the \ifnum lines to stop TeX from
  1134.     % continuing to look for a <number>.
  1135.     % 
  1136.     \ifnum\lccode\expandafter`\thearg=0\relax 
  1137.       \numericenumerate % a number (we hope)
  1138.     \else
  1139.       % It's a letter.
  1140.       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1141.         \lowercaseenumerate % lowercase letter
  1142.       \else
  1143.         \uppercaseenumerate % uppercase letter
  1144.       \fi
  1145.     \fi
  1146.   \else
  1147.     % Multiple tokens in the argument.  We hope it's a number.
  1148.     \numericenumerate
  1149.   \fi
  1150. % An @enumerate whose labels are integers.  The starting integer is
  1151. % given in \thearg.
  1152. \def\numericenumerate{%
  1153.   \itemno = \thearg
  1154.   \startenumeration{\the\itemno}%
  1155. % The starting (lowercase) letter is in \thearg.
  1156. \def\lowercaseenumerate{%
  1157.   \itemno = \expandafter`\thearg
  1158.   \startenumeration{%
  1159.     % Be sure we're not beyond the end of the alphabet.
  1160.     \ifnum\itemno=0
  1161.       \errmessage{No more lowercase letters in @enumerate; get a bigger
  1162.                   alphabet}%
  1163.     \fi
  1164.     \char\lccode\itemno
  1165. % The starting (uppercase) letter is in \thearg.
  1166. \def\uppercaseenumerate{%
  1167.   \itemno = \expandafter`\thearg
  1168.   \startenumeration{%
  1169.     % Be sure we're not beyond the end of the alphabet.
  1170.     \ifnum\itemno=0
  1171.       \errmessage{No more uppercase letters in @enumerate; get a bigger
  1172.                   alphabet}
  1173.     \fi
  1174.     \char\uccode\itemno
  1175. % Call itemizey, adding a period to the first argument and supplying the
  1176. % common last two arguments.  Also subtract one from the initial value in
  1177. % \itemno, since @item increments \itemno.
  1178. \def\startenumeration#1{%
  1179.   \advance\itemno by -1
  1180.   \itemizey{#1.}\Eenumerate\flushcr
  1181. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1182. % to @enumerate.
  1183. \def\alphaenumerate{\enumerate{a}}
  1184. \def\capsenumerate{\enumerate{A}}
  1185. \def\Ealphaenumerate{\Eenumerate}
  1186. \def\Ecapsenumerate{\Eenumerate}
  1187. % Definition of @item while inside @itemize.
  1188. \def\itemizeitem{%
  1189. \advance\itemno by 1
  1190. {\let\par=\endgraf \smallbreak}%
  1191. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  1192. {\parskip=0in \hskip 0pt
  1193. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1194. \vadjust{\penalty 1200}}%
  1195. \flushcr}
  1196. \message{indexing,}
  1197. % Index generation facilities
  1198. % Define \newwrite to be identical to plain tex's \newwrite
  1199. % except not \outer, so it can be used within \newindex.
  1200. {\catcode`\@=11
  1201. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  1202. % \newindex {foo} defines an index named foo.
  1203. % It automatically defines \fooindex such that
  1204. % \fooindex ...rest of line... puts an entry in the index foo.
  1205. % It also defines \fooindfile to be the number of the output channel for
  1206. % the file that    accumulates this index.  The file's extension is foo.
  1207. % The name of an index should be no more than 2 characters long
  1208. % for the sake of vms.
  1209. \def\newindex #1{
  1210. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1211. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1212. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1213. \noexpand\doindex {#1}}
  1214. % @defindex foo  ==  \newindex{foo}
  1215. \def\defindex{\parsearg\newindex}
  1216. % Define @defcodeindex, like @defindex except put all entries in @code.
  1217. \def\newcodeindex #1{
  1218. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1219. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1220. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1221. \noexpand\docodeindex {#1}}
  1222. \def\defcodeindex{\parsearg\newcodeindex}
  1223. % @synindex foo bar    makes index foo feed into index bar.
  1224. % Do this instead of @defindex foo if you don't want it as a separate index.
  1225. \def\synindex #1 #2 {%
  1226. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1227. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1228. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1229. \noexpand\doindex {#2}}%
  1230. % @syncodeindex foo bar   similar, but put all entries made for index foo
  1231. % inside @code.
  1232. \def\syncodeindex #1 #2 {%
  1233. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1234. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1235. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1236. \noexpand\docodeindex {#2}}%
  1237. % Define \doindex, the driver for all \fooindex macros.
  1238. % Argument #1 is generated by the calling \fooindex macro,
  1239. %  and it is "foo", the name of the index.
  1240. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1241. % This is because \doind is more useful to call from other macros.
  1242. % There is also \dosubind {index}{topic}{subtopic}
  1243. % which makes an entry in a two-level index such as the operation index.
  1244. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1245. \def\singleindexer #1{\doind{\indexname}{#1}}
  1246. % like the previous two, but they put @code around the argument.
  1247. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1248. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1249. \def\indexdummies{%
  1250. \def\_{{\realbackslash _}}%
  1251. \def\w{\realbackslash w }%
  1252. \def\bf{\realbackslash bf }%
  1253. \def\rm{\realbackslash rm }%
  1254. \def\sl{\realbackslash sl }%
  1255. \def\sf{\realbackslash sf}%
  1256. \def\tt{\realbackslash tt}%
  1257. \def\gtr{\realbackslash gtr}%
  1258. \def\less{\realbackslash less}%
  1259. \def\hat{\realbackslash hat}%
  1260. \def\char{\realbackslash char}%
  1261. \def\TeX{\realbackslash TeX}%
  1262. \def\dots{\realbackslash dots }%
  1263. \def\copyright{\realbackslash copyright }%
  1264. \def\tclose##1{\realbackslash tclose {##1}}%
  1265. \def\code##1{\realbackslash code {##1}}%
  1266. \def\samp##1{\realbackslash samp {##1}}%
  1267. \def\t##1{\realbackslash r {##1}}%
  1268. \def\r##1{\realbackslash r {##1}}%
  1269. \def\i##1{\realbackslash i {##1}}%
  1270. \def\b##1{\realbackslash b {##1}}%
  1271. \def\cite##1{\realbackslash cite {##1}}%
  1272. \def\key##1{\realbackslash key {##1}}%
  1273. \def\file##1{\realbackslash file {##1}}%
  1274. \def\var##1{\realbackslash var {##1}}%
  1275. \def\kbd##1{\realbackslash kbd {##1}}%
  1276. % \indexnofonts no-ops all font-change commands.
  1277. % This is used when outputting the strings to sort the index by.
  1278. \def\indexdummyfont#1{#1}
  1279. \def\indexdummytex{TeX}
  1280. \def\indexdummydots{...}
  1281. \def\indexnofonts{%
  1282. \let\w=\indexdummyfont
  1283. \let\t=\indexdummyfont
  1284. \let\r=\indexdummyfont
  1285. \let\i=\indexdummyfont
  1286. \let\b=\indexdummyfont
  1287. \let\emph=\indexdummyfont
  1288. \let\strong=\indexdummyfont
  1289. \let\cite=\indexdummyfont
  1290. \let\sc=\indexdummyfont
  1291. %Don't no-op \tt, since it isn't a user-level command
  1292. % and is used in the definitions of the active chars like <, >, |...
  1293. %\let\tt=\indexdummyfont
  1294. \let\tclose=\indexdummyfont
  1295. \let\code=\indexdummyfont
  1296. \let\file=\indexdummyfont
  1297. \let\samp=\indexdummyfont
  1298. \let\kbd=\indexdummyfont
  1299. \let\key=\indexdummyfont
  1300. \let\var=\indexdummyfont
  1301. \let\TeX=\indexdummytex
  1302. \let\dots=\indexdummydots
  1303. % To define \realbackslash, we must make \ not be an escape.
  1304. % We must first make another character (@) an escape
  1305. % so we do not become unable to do a definition.
  1306. {\catcode`\@=0 \catcode`\\=\other
  1307. @gdef@realbackslash{\}}
  1308. \let\indexbackslash=0  %overridden during \printindex.
  1309. \def\doind #1#2{%
  1310. {\count10=\lastpenalty%
  1311. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1312. \escapechar=`\\%
  1313. {\let\folio=0% Expand all macros now EXCEPT \folio
  1314. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1315. % so it will be output as is; and it will print as backslash in the indx.
  1316. % Now process the index-string once, with all font commands turned off,
  1317. % to get the string to sort the index by.
  1318. {\indexnofonts%
  1319. \xdef\temp1{#2}%
  1320. % Now produce the complete index entry.  We process the index-string again,
  1321. % this time with font commands expanded, to get what to print in the index.
  1322. \edef\temp{%
  1323. \write \csname#1indfile\endcsname{%
  1324. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1325. \temp}%
  1326. }\penalty\count10}}
  1327. \def\dosubind #1#2#3{%
  1328. {\count10=\lastpenalty%
  1329. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1330. \escapechar=`\\%
  1331. {\let\folio=0%
  1332. \def\rawbackslashxx{\indexbackslash}%
  1333. % Now process the index-string once, with all font commands turned off,
  1334. % to get the string to sort the index by.
  1335. {\indexnofonts%
  1336. \xdef\temp1{#2 #3}%
  1337. % Now produce the complete index entry.  We process the index-string again,
  1338. % this time with font commands expanded, to get what to print in the index.
  1339. \edef\temp{%
  1340. \write \csname#1indfile\endcsname{%
  1341. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1342. \temp}%
  1343. }\penalty\count10}}
  1344. % The index entry written in the file actually looks like
  1345. %  \entry {sortstring}{page}{topic}
  1346. %  \entry {sortstring}{page}{topic}{subtopic}
  1347. % The texindex program reads in these files and writes files
  1348. % containing these kinds of lines:
  1349. %  \initial {c}
  1350. %     before the first topic whose initial is c
  1351. %  \entry {topic}{pagelist}
  1352. %     for a topic that is used without subtopics
  1353. %  \primary {topic}
  1354. %     for the beginning of a topic that is used with subtopics
  1355. %  \secondary {subtopic}{pagelist}
  1356. %     for each subtopic.
  1357. % Define the user-accessible indexing commands 
  1358. % @findex, @vindex, @kindex, @cindex.
  1359. \def\findex {\fnindex}
  1360. \def\kindex {\kyindex}
  1361. \def\cindex {\cpindex}
  1362. \def\vindex {\vrindex}
  1363. \def\tindex {\tpindex}
  1364. \def\pindex {\pgindex}
  1365. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1366. {\obeylines %
  1367. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1368. \dosubind{cp}{#2}{#1}}}
  1369. % Define the macros used in formatting output of the sorted index material.
  1370. % This is what you call to cause a particular index to get printed.
  1371. % Write
  1372. % @unnumbered Function Index
  1373. % @printindex fn
  1374. \def\printindex{\parsearg\doprintindex}
  1375. \def\doprintindex#1{%
  1376.   \tex
  1377.   \dobreak \chapheadingskip {10000}
  1378.   \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1379.   \catcode`\$=\other\catcode`\_=\other
  1380.   \catcode`\~=\other
  1381.   % The following don't help, since the chars were translated
  1382.   % when the raw index was written, and their fonts were discarded
  1383.   % due to \indexnofonts.
  1384.   %\catcode`\"=\active
  1385.   %\catcode`\^=\active
  1386.   %\catcode`\_=\active
  1387.   %\catcode`\|=\active
  1388.   %\catcode`\<=\active
  1389.   %\catcode`\>=\active
  1390.   % %
  1391.   \def\indexbackslash{\rawbackslashxx}
  1392.   \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1393.   \begindoublecolumns
  1394.   % See if the index file exists and is nonempty.
  1395.   \openin 1 \jobname.#1s
  1396.   \ifeof 1 
  1397.     % \enddoublecolumns gets confused if there is no text in the index,
  1398.     % and it loses the chapter title and the aux file entries for the
  1399.     % index.  The easiest way to prevent this problem is to make sure
  1400.     % there is some text.
  1401.     (Index is nonexistent)
  1402.     \else
  1403.     %
  1404.     % If the index file exists but is empty, then \openin leaves \ifeof
  1405.     % false.  We have to make TeX try to read something from the file, so
  1406.     % it can discover if there is anything in it.
  1407.     \read 1 to \temp
  1408.     \ifeof 1
  1409.       (Index is empty)
  1410.     \else
  1411.       \input \jobname.#1s
  1412.     \fi
  1413.   \fi
  1414.   \closein 1
  1415.   \enddoublecolumns
  1416.   \Etex
  1417. % These macros are used by the sorted index file itself.
  1418. % Change them to control the appearance of the index.
  1419. % Same as \bigskipamount except no shrink.
  1420. % \balancecolumns gets confused if there is any shrink.
  1421. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1422. \def\initial #1{%
  1423. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1424. \ifdim\lastskip<\initialskipamount
  1425. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1426. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1427. % This typesets a paragraph consisting of #1, dot leaders, and then #2
  1428. % flush to the right margin.  It is used for index and table of contents
  1429. % entries.  The paragraph is indented by \leftskip.
  1430. \def\entry #1#2{\begingroup
  1431.   % Start a new paragraph if necessary, so our assignments below can't
  1432.   % affect previous text.
  1433.   \par
  1434.   % Do not fill out the last line with white space.
  1435.   \parfillskip = 0in
  1436.   % No extra space above this paragraph.
  1437.   \parskip = 0in
  1438.   % Do not prefer a separate line ending with a hyphen to fewer lines.
  1439.   \finalhyphendemerits = 0
  1440.   % \hangindent is only relevant when the entry text and page number
  1441.   % don't both fit on one line.  In that case, bob suggests starting the
  1442.   % dots pretty far over on the line.  Unfortunately, a large
  1443.   % indentation looks wrong when the entry text itself is broken across
  1444.   % lines.  So we use a small indentation and put up with long leaders.
  1445.   % \hangafter is reset to 1 (which is the value we want) at the start
  1446.   % of each paragraph, so we need not do anything with that.
  1447.   \hangindent=2em
  1448.   % When the entry text needs to be broken, just fill out the first line
  1449.   % with blank space.
  1450.   \rightskip = 0pt plus1fil
  1451.   % Start a ``paragraph'' for the index entry so the line breaking
  1452.   % parameters we've set above will have an effect.
  1453.   \noindent
  1454.   % Insert the text of the index entry.  TeX will do line-breaking on it.
  1455.   #1%
  1456.   % If we must, put the page number on a line of its own, and fill out
  1457.   % this line with blank space.  (The \hfil is overwhelmed with the
  1458.   % fill leaders glue in \indexdotfill if the page number does fit.)
  1459.   \hfil\penalty50
  1460.   \null\nobreak\indexdotfill % Have leaders before the page number.
  1461.   % The `\ ' here is removed by the implicit \unskip that TeX does as
  1462.   % part of (the primitive) \par.  Without it, a spurious underfull
  1463.   % \hbox ensues.
  1464.   \ #2% The page number ends the paragraph.
  1465.   \par
  1466. \endgroup}
  1467. % Like \dotfill except takes at least 1 em.
  1468. \def\indexdotfill{\cleaders
  1469.   \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill}
  1470. \def\primary #1{\line{#1\hfil}}
  1471. \newskip\secondaryindent \secondaryindent=0.5cm
  1472. \def\secondary #1#2{
  1473. {\parfillskip=0in \parskip=0in
  1474. \hangindent =1in \hangafter=1
  1475. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  1476. %% Define two-column mode, which is used in indexes.
  1477. %% Adapted from the TeXbook, page 416.
  1478. \catcode `\@=11
  1479. \newbox\partialpage
  1480. \newdimen\doublecolumnhsize
  1481. \def\begindoublecolumns{\begingroup
  1482.   % Grab any single-column material above us.
  1483.   \output = {\global\setbox\partialpage
  1484.     =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
  1485.   \eject
  1486.   % Now switch to the double-column output routine.
  1487.   \output={\doublecolumnout}%
  1488.   % Change the page size parameters.  We could do this once outside this
  1489.   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  1490.   % format, but then we repeat the same computation.  Repeating a couple
  1491.   % of assignments once per index is clearly meaningless for the
  1492.   % execution time, so we may as well do it once.
  1493.   % First we halve the line length, less a little for the gutter between
  1494.   % the columns.  We compute the gutter based on the line length, so it
  1495.   % changes automatically with the paper format.  The magic constant
  1496.   % below is chosen so that the gutter has the same value (well, +- <
  1497.   % 1pt) as it did when we hard-coded it.
  1498.   % We put the result in a separate register, \doublecolumhsize, so we
  1499.   % can restore it in \pagesofar, after \hsize itself has (potentially)
  1500.   % been clobbered.
  1501.   \doublecolumnhsize = \hsize
  1502.     \advance\doublecolumnhsize by -.04154\hsize
  1503.     \divide\doublecolumnhsize by 2
  1504.   \hsize = \doublecolumnhsize
  1505.   % Double the \vsize as well.  (We don't need a separate register here,
  1506.   % since nobody clobbers \vsize.)
  1507.   \vsize = 2\vsize
  1508.   \doublecolumnpagegoal
  1509. \def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage}
  1510. \def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1511.   \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage
  1512.   \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1}
  1513.   \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3}
  1514.   \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1515.   \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1516. \def\doublecolumnpagegoal{%
  1517.   \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@
  1518. \def\pagesofar{\unvbox\partialpage %
  1519.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1520.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1521. \def\doublecolumnout{%
  1522.   \setbox5=\copy255
  1523.   {\vbadness=10000 \doublecolumnsplit}
  1524.   \ifvbox255
  1525.     \setbox0=\vtop to\dimen@{\unvbox0}
  1526.     \setbox2=\vtop to\dimen@{\unvbox2}
  1527.     \onepageout\pagesofar \unvbox255 \penalty\outputpenalty
  1528.   \else
  1529.     \setbox0=\vbox{\unvbox5}
  1530.     \ifvbox0
  1531.       \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1532.       \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1533.       {\vbadness=10000
  1534.     \loop \global\setbox5=\copy0
  1535.           \setbox1=\vsplit5 to\dimen@
  1536.           \setbox3=\vsplit5 to\dimen@
  1537.           \ifvbox5 \global\advance\dimen@ by1pt \repeat
  1538.         \setbox0=\vbox to\dimen@{\unvbox1}
  1539.         \setbox2=\vbox to\dimen@{\unvbox3}
  1540.         \global\setbox\partialpage=\vbox{\pagesofar}
  1541.         \doublecolumnpagegoal
  1542.       }
  1543.     \fi
  1544.   \fi
  1545. \catcode `\@=\other
  1546. \message{sectioning,}
  1547. % Define chapters, sections, etc.
  1548. \newcount \chapno
  1549. \newcount \secno        \secno=0
  1550. \newcount \subsecno     \subsecno=0
  1551. \newcount \subsubsecno  \subsubsecno=0
  1552. % This counter is funny since it counts through charcodes of letters A, B, ...
  1553. \newcount \appendixno  \appendixno = `\@
  1554. \def\appendixletter{\char\the\appendixno}
  1555. \newwrite \contentsfile
  1556. % This is called from \setfilename.
  1557. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1558. % Each @chapter defines this as the name of the chapter.
  1559. % page headings and footings can use it.  @section does likewise
  1560. \def\thischapter{} \def\thissection{}
  1561. \def\seccheck#1{\if \pageno<0 %
  1562. \errmessage{@#1 not allowed after generating table of contents}\fi
  1563. \def\chapternofonts{%
  1564. \let\rawbackslash=\relax%
  1565. \let\frenchspacing=\relax%
  1566. \def\result{\realbackslash result}
  1567. \def\equiv{\realbackslash equiv}
  1568. \def\expansion{\realbackslash expansion}
  1569. \def\print{\realbackslash print}
  1570. \def\TeX{\realbackslash TeX}
  1571. \def\dots{\realbackslash dots}
  1572. \def\copyright{\realbackslash copyright}
  1573. \def\tt{\realbackslash tt}
  1574. \def\bf{\realbackslash bf }
  1575. \def\w{\realbackslash w}
  1576. \def\less{\realbackslash less}
  1577. \def\gtr{\realbackslash gtr}
  1578. \def\hat{\realbackslash hat}
  1579. \def\char{\realbackslash char}
  1580. \def\tclose##1{\realbackslash tclose {##1}}
  1581. \def\code##1{\realbackslash code {##1}}
  1582. \def\samp##1{\realbackslash samp {##1}}
  1583. \def\r##1{\realbackslash r {##1}}
  1584. \def\b##1{\realbackslash b {##1}}
  1585. \def\key##1{\realbackslash key {##1}}
  1586. \def\file##1{\realbackslash file {##1}}
  1587. \def\kbd##1{\realbackslash kbd {##1}}
  1588. % These are redefined because @smartitalic wouldn't work inside xdef.
  1589. \def\i##1{\realbackslash i {##1}}
  1590. \def\cite##1{\realbackslash cite {##1}}
  1591. \def\var##1{\realbackslash var {##1}}
  1592. \def\emph##1{\realbackslash emph {##1}}
  1593. \def\dfn##1{\realbackslash dfn {##1}}
  1594. \def\thischaptername{No Chapter Title}
  1595. \outer\def\chapter{\parsearg\chapterzzz}
  1596. \def\chapterzzz #1{\seccheck{chapter}%
  1597. \secno=0 \subsecno=0 \subsubsecno=0
  1598. \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1599. \chapmacro {#1}{\the\chapno}%
  1600. \gdef\thissection{#1}%
  1601. \gdef\thischaptername{#1}%
  1602. % We don't substitute the actual chapter name into \thischapter
  1603. % because we don't want its macros evaluated now.
  1604. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1605. {\chapternofonts%
  1606. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1607. \escapechar=`\\%
  1608. \write \contentsfile \temp  %
  1609. \donoderef %
  1610. \global\let\section = \numberedsec
  1611. \global\let\subsection = \numberedsubsec
  1612. \global\let\subsubsection = \numberedsubsubsec
  1613. \outer\def\appendix{\parsearg\appendixzzz}
  1614. \def\appendixzzz #1{\seccheck{appendix}%
  1615. \secno=0 \subsecno=0 \subsubsecno=0
  1616. \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1617. \chapmacro {#1}{Appendix \appendixletter}%
  1618. \gdef\thissection{#1}%
  1619. \gdef\thischaptername{#1}%
  1620. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  1621. {\chapternofonts%
  1622. \edef\temp{{\realbackslash chapentry 
  1623.   {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1624. \escapechar=`\\%
  1625. \write \contentsfile \temp  %
  1626. \appendixnoderef %
  1627. \global\let\section = \appendixsec
  1628. \global\let\subsection = \appendixsubsec
  1629. \global\let\subsubsection = \appendixsubsubsec
  1630. \outer\def\top{\parsearg\unnumberedzzz}
  1631. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1632. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1633. \secno=0 \subsecno=0 \subsubsecno=0
  1634. % This used to be simply \message{#1}, but TeX fully expands the
  1635. % argument to \message.  Therefore, if #1 contained @-commands, TeX
  1636. % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
  1637. % expanded @cite (which turns out to cause errors because \cite is meant
  1638. % to be executed, not expanded).  
  1639. % Anyway, we don't want the fully-expanded definition of @cite to appear
  1640. % as a result of the \message, we just want `@cite' itself.  We use
  1641. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  1642. % simply yielding the contents of the <toks register>.
  1643. \toks0 = {#1}\message{(\the\toks0)}%
  1644. \unnumbchapmacro {#1}%
  1645. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1646. {\chapternofonts%
  1647. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1648. \escapechar=`\\%
  1649. \write \contentsfile \temp  %
  1650. \unnumbnoderef %
  1651. \global\let\section = \unnumberedsec
  1652. \global\let\subsection = \unnumberedsubsec
  1653. \global\let\subsubsection = \unnumberedsubsubsec
  1654. \outer\def\numberedsec{\parsearg\seczzz}
  1655. \def\seczzz #1{\seccheck{section}%
  1656. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1657. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1658. {\chapternofonts%
  1659. \edef\temp{{\realbackslash secentry %
  1660. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1661. \escapechar=`\\%
  1662. \write \contentsfile \temp %
  1663. \donoderef %
  1664. \penalty 10000 %
  1665. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1666. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1667. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1668. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1669. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1670. {\chapternofonts%
  1671. \edef\temp{{\realbackslash secentry %
  1672. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1673. \escapechar=`\\%
  1674. \write \contentsfile \temp %
  1675. \appendixnoderef %
  1676. \penalty 10000 %
  1677. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1678. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1679. \plainsecheading {#1}\gdef\thissection{#1}%
  1680. {\chapternofonts%
  1681. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1682. \escapechar=`\\%
  1683. \write \contentsfile \temp %
  1684. \unnumbnoderef %
  1685. \penalty 10000 %
  1686. \outer\def\numberedsubsec{\parsearg\numberedsubseczzz}
  1687. \def\numberedsubseczzz #1{\seccheck{subsection}%
  1688. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1689. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1690. {\chapternofonts%
  1691. \edef\temp{{\realbackslash subsecentry %
  1692. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1693. \escapechar=`\\%
  1694. \write \contentsfile \temp %
  1695. \donoderef %
  1696. \penalty 10000 %
  1697. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1698. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1699. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1700. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1701. {\chapternofonts%
  1702. \edef\temp{{\realbackslash subsecentry %
  1703. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1704. \escapechar=`\\%
  1705. \write \contentsfile \temp %
  1706. \appendixnoderef %
  1707. \penalty 10000 %
  1708. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1709. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1710. \plainsecheading {#1}\gdef\thissection{#1}%
  1711. {\chapternofonts%
  1712. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1713. \escapechar=`\\%
  1714. \write \contentsfile \temp %
  1715. \unnumbnoderef %
  1716. \penalty 10000 %
  1717. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz}
  1718. \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
  1719. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1720. \subsubsecheading {#1}
  1721.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1722. {\chapternofonts%
  1723. \edef\temp{{\realbackslash subsubsecentry %
  1724.   {#1}
  1725.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
  1726.   {\noexpand\folio}}}%
  1727. \escapechar=`\\%
  1728. \write \contentsfile \temp %
  1729. \donoderef %
  1730. \penalty 10000 %
  1731. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1732. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1733. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1734. \subsubsecheading {#1}
  1735.   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1736. {\chapternofonts%
  1737. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1738.   {\appendixletter}
  1739.   {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
  1740. \escapechar=`\\%
  1741. \write \contentsfile \temp %
  1742. \appendixnoderef %
  1743. \penalty 10000 %
  1744. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1745. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1746. \plainsecheading {#1}\gdef\thissection{#1}%
  1747. {\chapternofonts%
  1748. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1749. \escapechar=`\\%
  1750. \write \contentsfile \temp %
  1751. \unnumbnoderef %
  1752. \penalty 10000 %
  1753. % These are variants which are not "outer", so they can appear in @ifinfo.
  1754. % Actually, they should now be obsolete; ordinary section commands should work.
  1755. \def\infotop{\parsearg\unnumberedzzz}
  1756. \def\infounnumbered{\parsearg\unnumberedzzz}
  1757. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1758. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1759. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1760. \def\infoappendix{\parsearg\appendixzzz}
  1761. \def\infoappendixsec{\parsearg\appendixseczzz}
  1762. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1763. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1764. \def\infochapter{\parsearg\chapterzzz}
  1765. \def\infosection{\parsearg\sectionzzz}
  1766. \def\infosubsection{\parsearg\subsectionzzz}
  1767. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1768. % These macros control what the section commands do, according
  1769. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  1770. % Define them by default for a numbered chapter.
  1771. \global\let\section = \numberedsec
  1772. \global\let\subsection = \numberedsubsec
  1773. \global\let\subsubsection = \numberedsubsubsec
  1774. % Define @majorheading, @heading and @subheading
  1775. % NOTE on use of \vbox for chapter headings, section headings, and
  1776. % such:
  1777. %    1) We use \vbox rather than the earlier \line to permit
  1778. %       overlong headings to fold.
  1779. %    2) \hyphenpenalty is set to 10000 because hyphenation in a
  1780. %       heading is obnoxious; this forbids it.
  1781. %       3) Likewise, headings look best if no \parindent is used, and
  1782. %          if justification is not attempted.  Hence \raggedright.
  1783. \def\majorheading{\parsearg\majorheadingzzz}
  1784. \def\majorheadingzzz #1{%
  1785. {\advance\chapheadingskip by 10pt \chapbreak }%
  1786. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1787.                   \parindent=0pt\raggedright
  1788.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  1789. \def\chapheading{\parsearg\chapheadingzzz}
  1790. \def\chapheadingzzz #1{\chapbreak %
  1791. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1792.                   \parindent=0pt\raggedright
  1793.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  1794. \def\heading{\parsearg\secheadingi}
  1795. \def\subheading{\parsearg\subsecheadingi}
  1796. \def\subsubheading{\parsearg\subsubsecheadingi}
  1797. % These macros generate a chapter, section, etc. heading only
  1798. % (including whitespace, linebreaking, etc. around it),
  1799. % given all the information in convenient, parsed form.
  1800. %%% Args are the skip and penalty (usually negative)
  1801. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1802. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1803. %%% Define plain chapter starts, and page on/off switching for it
  1804. % Parameter controlling skip before chapter headings (if needed)
  1805. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1806. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1807. \def\chappager{\par\vfill\supereject}
  1808. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1809. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1810. \def\CHAPPAGoff{
  1811. \global\let\pchapsepmacro=\chapbreak
  1812. \global\let\pagealignmacro=\chappager}
  1813. \def\CHAPPAGon{
  1814. \global\let\pchapsepmacro=\chappager
  1815. \global\let\pagealignmacro=\chappager
  1816. \global\def\HEADINGSon{\HEADINGSsingle}}
  1817. \def\CHAPPAGodd{
  1818. \global\let\pchapsepmacro=\chapoddpage
  1819. \global\let\pagealignmacro=\chapoddpage
  1820. \global\def\HEADINGSon{\HEADINGSdouble}}
  1821. \CHAPPAGon
  1822. \def\CHAPFplain{
  1823. \global\let\chapmacro=\chfplain
  1824. \global\let\unnumbchapmacro=\unnchfplain}
  1825. \def\chfplain #1#2{%
  1826.   \pchapsepmacro
  1827.     \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1828.                      \parindent=0pt\raggedright
  1829.                      \rm #2\enspace #1}%
  1830.   \bigskip
  1831.   \penalty5000
  1832. \def\unnchfplain #1{%
  1833. \pchapsepmacro %
  1834. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1835.                   \parindent=0pt\raggedright
  1836.                   \rm #1\hfill}}\bigskip \par\penalty 10000 %
  1837. \CHAPFplain % The default
  1838. \def\unnchfopen #1{%
  1839. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1840.                        \parindent=0pt\raggedright
  1841.                        \rm #1\hfill}}\bigskip \par\penalty 10000 %
  1842. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1843. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1844. \par\penalty 5000 %
  1845. \def\CHAPFopen{
  1846. \global\let\chapmacro=\chfopen
  1847. \global\let\unnumbchapmacro=\unnchfopen}
  1848. % Parameter controlling skip before section headings.
  1849. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1850. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1851. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1852. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1853. % @paragraphindent  is defined for the Info formatting commands only.
  1854. \let\paragraphindent=\comment
  1855. % Section fonts are the base font at magstep2, which produces
  1856. % a size a bit more than 14 points in the default situation.    
  1857. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  1858. \def\plainsecheading #1{\secheadingi {#1}}
  1859. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  1860. \secheadingbreak}%
  1861. {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1862.                  \parindent=0pt\raggedright
  1863.                  \rm #1\hfill}}%
  1864. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1865. % Subsection fonts are the base font at magstep1, 
  1866. % which produces a size of 12 points.
  1867. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  1868. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  1869. \subsecheadingbreak}%
  1870. {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1871.                      \parindent=0pt\raggedright
  1872.                      \rm #1\hfill}}%
  1873. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1874. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  1875.                   % Perhaps make sssec fonts scaled
  1876.                   % magstep half
  1877. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  1878. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  1879. \subsecheadingbreak}%
  1880. {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1881.                        \parindent=0pt\raggedright
  1882.                        \rm #1\hfill}}%
  1883. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  1884. \message{toc printing,}
  1885. % Finish up the main text and prepare to read what we've written
  1886. % to \contentsfile.
  1887. \newskip\contentsrightmargin \contentsrightmargin=1in
  1888. \def\startcontents#1{%
  1889.    \pagealignmacro
  1890.    \immediate\closeout \contentsfile
  1891.    \ifnum \pageno>0
  1892.       \pageno = -1        % Request roman numbered pages.
  1893.    \fi
  1894.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  1895.    % It is abundantly clear what they are.
  1896.    \unnumbchapmacro{#1}\def\thischapter{}%
  1897.    \begingroup           % Set up to handle contents files properly.
  1898.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  1899.       \raggedbottom             % Worry more about breakpoints than the bottom.
  1900.       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  1901. % Normal (long) toc.
  1902. \outer\def\contents{%
  1903.    \startcontents{Table of Contents}%
  1904.       \input \jobname.toc
  1905.    \endgroup
  1906.    \vfill \eject
  1907. % And just the chapters.
  1908. \outer\def\summarycontents{%
  1909.    \startcontents{Short Contents}%
  1910.       %
  1911.       \let\chapentry = \shortchapentry
  1912.       \let\unnumbchapentry = \shortunnumberedentry
  1913.       % We want a true roman here for the page numbers.
  1914.       \secfonts
  1915.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  1916.       \rm
  1917.       \advance\baselineskip by 1pt % Open it up a little.
  1918.       \def\secentry ##1##2##3##4{}
  1919.       \def\unnumbsecentry ##1##2{}
  1920.       \def\subsecentry ##1##2##3##4##5{}
  1921.       \def\unnumbsubsecentry ##1##2{}
  1922.       \def\subsubsecentry ##1##2##3##4##5##6{}
  1923.       \def\unnumbsubsubsecentry ##1##2{}
  1924.       \input \jobname.toc
  1925.    \endgroup
  1926.    \vfill \eject
  1927. \let\shortcontents = \summarycontents
  1928. % These macros generate individual entries in the table of contents.
  1929. % The first argument is the chapter or section name.
  1930. % The last argument is the page number.
  1931. % The arguments in between are the chapter number, section number, ...
  1932. % Chapter-level things, for both the long and short contents.
  1933. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  1934. % See comments in \dochapentry re vbox and related settings
  1935. \def\shortchapentry#1#2#3{%
  1936.   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
  1937. % Typeset the label for a chapter or appendix for the short contents.
  1938. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  1939. % We could simplify the code here by writing out an \appendixentry
  1940. % command in the toc file for appendices, instead of using \chapentry
  1941. % for both, but it doesn't seem worth it.
  1942. \setbox0 = \hbox{\shortcontrm Appendix }
  1943. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  1944. \def\shortchaplabel#1{%
  1945.   % We typeset #1 in a box of constant width, regardless of the text of
  1946.   % #1, so the chapter titles will come out aligned.
  1947.   \setbox0 = \hbox{#1}%
  1948.   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  1949.   % This space should be plenty, since a single number is .5em, and the
  1950.   % widest letter (M) is 1em, at least in the Computer Modern fonts.
  1951.   % (This space doesn't include the extra space that gets added after
  1952.   % the label; that gets put in in \shortchapentry above.)
  1953.   \advance\dimen0 by 1.1em
  1954.   \hbox to \dimen0{#1\hfil}%
  1955. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  1956. \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
  1957. % Sections.
  1958. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  1959. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  1960. % Subsections.
  1961. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  1962. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  1963. % And subsubsections.
  1964. \def\subsubsecentry#1#2#3#4#5#6{%
  1965.   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  1966. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  1967. % This parameter controls the indentation of the various levels.
  1968. \newdimen\tocindent \tocindent = 3pc
  1969. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  1970. % page number.
  1971. % If the toc has to be broken over pages, we would want to be at chapters 
  1972. % if at all possible; hence the \penalty.
  1973. \def\dochapentry#1#2{%
  1974.    \penalty-300 \vskip\baselineskip
  1975.    \begingroup
  1976.      \chapentryfonts
  1977.      \tocentry{#1}{\dopageno{#2}}%
  1978.    \endgroup
  1979.    \nobreak\vskip .25\baselineskip
  1980. \def\dosecentry#1#2{\begingroup
  1981.   \secentryfonts \leftskip=\tocindent
  1982.   \tocentry{#1}{\dopageno{#2}}%
  1983. \endgroup}
  1984. \def\dosubsecentry#1#2{\begingroup
  1985.   \subsecentryfonts \leftskip=2\tocindent
  1986.   \tocentry{#1}{\dopageno{#2}}%
  1987. \endgroup}
  1988. \def\dosubsubsecentry#1#2{\begingroup
  1989.   \subsubsecentryfonts \leftskip=3\tocindent
  1990.   \tocentry{#1}{\dopageno{#2}}%
  1991. \endgroup}
  1992. % Final typesetting of a toc entry; we use the same \entry macro as for
  1993. % the index entries, but we want to suppress hyphenation here.  (We
  1994. % can't do that in the \entry macro, since index entries might consist
  1995. % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
  1996. \def\tocentry#1#2{\begingroup
  1997.   \hyphenpenalty = 10000
  1998.   \entry{#1}{#2}%
  1999. \endgroup}
  2000. % Space between chapter (or whatever) number and the title.
  2001. \def\labelspace{\hskip1em \relax}
  2002. \def\dopageno#1{{\rm #1}}
  2003. \def\doshortpageno#1{{\rm #1}}
  2004. \def\chapentryfonts{\secfonts \rm}
  2005. \def\secentryfonts{\textfonts}
  2006. \let\subsecentryfonts = \textfonts
  2007. \let\subsubsecentryfonts = \textfonts
  2008. \message{environments,}
  2009. % Since these characters are used in examples, it should be an even number of 
  2010. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  2011. % Furthermore, these definitions must come after we define our fonts.
  2012. \newbox\dblarrowbox    \newbox\longdblarrowbox
  2013. \newbox\pushcharbox    \newbox\bullbox
  2014. \newbox\equivbox       \newbox\errorbox
  2015. \let\ptexequiv = \equiv
  2016. %{\tentt
  2017. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  2018. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  2019. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  2020. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  2021. % Adapted from the manmac format (p.420 of TeXbook)
  2022. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  2023. %                                      depth .1ex\hfil}
  2024. \def\point{$\star$}
  2025. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  2026. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  2027. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  2028. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  2029. % Adapted from the TeXbook's \boxit.
  2030. {\tentt \global\dimen0 = 3em}% Width of the box.
  2031. \dimen2 = .55pt % Thickness of rules
  2032. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  2033. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  2034. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  2035.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  2036.    \advance\hsize by -2\dimen2 % Rules.
  2037.    \vbox{
  2038.       \hrule height\dimen2
  2039.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  2040.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  2041.          \kern3pt\vrule width\dimen2}% Space to right.
  2042.       \hrule height\dimen2}
  2043.     \hfil}
  2044. % The @error{} command.
  2045. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  2046. % @tex ... @end tex    escapes into raw Tex temporarily.
  2047. % One exception: @ is still an escape character, so that @end tex works.
  2048. % But \@ or @@ will get a plain tex @ character.
  2049. \def\tex{\begingroup
  2050. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  2051. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  2052. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  2053. \catcode `\%=14
  2054. \catcode 43=12
  2055. \catcode`\"=12
  2056. \catcode`\==12
  2057. \catcode`\|=12
  2058. \catcode`\<=12
  2059. \catcode`\>=12
  2060. \escapechar=`\\
  2061. \let\{=\ptexlbrace
  2062. \let\}=\ptexrbrace
  2063. \let\.=\ptexdot
  2064. \let\*=\ptexstar
  2065. \let\dots=\ptexdots
  2066. \def\@{@}%
  2067. \let\bullet=\ptexbullet
  2068. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  2069. \let\L=\ptexL
  2070. \let\Etex=\endgroup}
  2071. % Define @lisp ... @endlisp.
  2072. % @lisp does a \begingroup so it can rebind things,
  2073. % including the definition of @endlisp (which normally is erroneous).
  2074. % Amount to narrow the margins by for @lisp.
  2075. \newskip\lispnarrowing \lispnarrowing=0.4in
  2076. % This is the definition that ^M gets inside @lisp
  2077. % phr: changed space to \null, to avoid overfull hbox problems.
  2078. {\obeyspaces%
  2079. \gdef\lisppar{\null\endgraf}}
  2080. % Cause \obeyspaces to make each Space cause a word-separation
  2081. % rather than the default which is that it acts punctuation.
  2082. % This is because space in tt font looks funny.
  2083. {\obeyspaces %
  2084. \gdef\sepspaces{\def {\ }}}
  2085. % This space is always present above and below environments.
  2086. \newskip\envskipamount \envskipamount = 0pt
  2087. % Make spacing and below environment symmetrical.
  2088. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  2089. \endgraf \ifdim\lastskip<\envskipamount
  2090. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  2091. \let\afterenvbreak = \aboveenvbreak
  2092. % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
  2093. \let\nonarrowing=\relax
  2094. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2095. % \cartouche: draw rectangle w/rounded corners around argument
  2096. \font\circle=lcircle10
  2097. \newdimen\circthick
  2098. \newdimen\cartouter\newdimen\cartinner
  2099. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  2100. \circthick=\fontdimen8\circle
  2101. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  2102. \def\ctr{{\hskip 6pt\circle\char'010}}
  2103. \def\cbl{{\circle\char'012\hskip -6pt}}
  2104. \def\cbr{{\hskip 6pt\circle\char'011}}
  2105. \def\carttop{\hbox to \cartouter{\hskip\lskip
  2106.     \ctl\leaders\hrule height\circthick\hfil\ctr
  2107.     \hskip\rskip}}
  2108. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  2109.     \cbl\leaders\hrule height\circthick\hfil\cbr
  2110.     \hskip\rskip}}
  2111. \newskip\lskip\newskip\rskip
  2112. \long\def\cartouche{%
  2113. \begingroup
  2114.     \lskip=\leftskip \rskip=\rightskip
  2115.     \leftskip=0pt\rightskip=0pt %we want these *outside*.
  2116.     \cartinner=\hsize \advance\cartinner by-\lskip 
  2117.                \advance\cartinner by-\rskip
  2118.     \cartouter=\hsize
  2119.     \advance\cartouter by 18pt % allow for 3pt kerns on either
  2120. %                     side, and for 6pt waste from
  2121. %                     each corner char
  2122.     \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  2123.     % Flag to tell @lisp, etc., not to narrow margin.
  2124.     \let\nonarrowing=\comment
  2125.     \vbox\bgroup
  2126.         \baselineskip=0pt\parskip=0pt\lineskip=0pt
  2127.         \carttop
  2128.         \hbox\bgroup
  2129.             \hskip\lskip
  2130.             \vrule\kern3pt
  2131.             \vbox\bgroup
  2132.                 \hsize=\cartinner
  2133.                 \kern3pt
  2134.                 \begingroup
  2135.                     \baselineskip=\normbskip
  2136.                     \lineskip=\normlskip
  2137.                     \parskip=\normpskip
  2138.                     \vskip -\parskip
  2139. \def\Ecartouche{%
  2140.                 \endgroup
  2141.                 \kern3pt
  2142.             \egroup
  2143.             \kern3pt\vrule
  2144.             \hskip\rskip
  2145.         \egroup
  2146.         \cartbot
  2147.     \egroup
  2148. \endgroup
  2149. \def\lisp{\aboveenvbreak
  2150. \begingroup\inENV % This group ends at the end of the @lisp body
  2151. \hfuzz=12truept % Don't be fussy
  2152. % Make spaces be word-separators rather than space tokens.
  2153. \sepspaces %
  2154. % Single space lines
  2155. \singlespace %
  2156. % The following causes blank lines not to be ignored
  2157. % by adding a space to the end of each line.
  2158. \let\par=\lisppar
  2159. \def\Elisp{\endgroup\afterenvbreak}%
  2160. \parskip=0pt
  2161. % @cartouche defines \nonarrowing to inhibit narrowing
  2162. % at next level down.
  2163. \ifx\nonarrowing\relax
  2164. \advance \leftskip by \lispnarrowing
  2165. \exdentamount=\lispnarrowing
  2166. \let\exdent=\nofillexdent
  2167. \let\nonarrowing=\relax
  2168. \parindent=0pt
  2169. \obeyspaces \obeylines \tt \rawbackslash
  2170. \gobble
  2171. % Define the \E... control sequence only if we are inside the
  2172. % environment, so the error checking in \end will work.
  2173. % We must call \lisp last in the definition, since it reads the
  2174. % return following the @example (or whatever) command.
  2175. \def\example{\begingroup \def\Eexample{\Elisp\endgroup}\lisp}
  2176. \def\smallexample{\begingroup \def\Esmallexample{\Elisp\endgroup}\lisp}
  2177. % Macro for 9 pt. examples, necessary to print with 5" lines.
  2178. % From Pavel@xerox.  This is not really used unless the
  2179. % @smallbook command is given.
  2180. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  2181. %            This group ends at the end of the @lisp body
  2182. \hfuzz=12truept % Don't be fussy
  2183. % Make spaces be word-separators rather than space tokens.
  2184. \sepspaces %
  2185. % Single space lines
  2186. \singlespace %
  2187. % The following causes blank lines not to be ignored
  2188. % by adding a space to the end of each line.
  2189. \let\par=\lisppar
  2190. \def\Esmalllisp{\endgroup\afterenvbreak}%
  2191. %%%% Smaller baseline skip for small examples.
  2192. \baselineskip 10pt
  2193. \parskip=0pt
  2194. % @cartouche defines \nonarrowing to inhibit narrowing
  2195. % at next level down.
  2196. \ifx\nonarrowing\relax
  2197. \advance \leftskip by \lispnarrowing
  2198. \exdentamount=\lispnarrowing
  2199. \let\exdent=\nofillexdent
  2200. \let\nonarrowing=\relax
  2201. \parindent=0pt
  2202. \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
  2203. \def\next##1{}\next}
  2204. % This is @display; same as @lisp except use roman font.
  2205. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  2206. \aboveenvbreak
  2207. % Make spaces be word-separators rather than space tokens.
  2208. \sepspaces %
  2209. % Single space lines
  2210. \singlespace %
  2211. % The following causes blank lines not to be ignored
  2212. % by adding a space to the end of each line.
  2213. \let\par=\lisppar
  2214. \def\Edisplay{\endgroup\afterenvbreak}%
  2215. \parskip=0pt
  2216. % @cartouche defines \nonarrowing to inhibit narrowing
  2217. % at next level down.
  2218. \ifx\nonarrowing\relax
  2219. \advance \leftskip by \lispnarrowing
  2220. \exdentamount=\lispnarrowing
  2221. \let\exdent=\nofillexdent
  2222. \let\nonarrowing=\relax
  2223. \parindent=0pt
  2224. \obeyspaces \obeylines
  2225. \def\next##1{}\next}
  2226. % This is @format; same as @lisp except use roman font and don't narrow margins
  2227. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  2228. \aboveenvbreak
  2229. % Make spaces be word-separators rather than space tokens.
  2230. \sepspaces %
  2231. \singlespace %
  2232. % The following causes blank lines not to be ignored
  2233. % by adding a space to the end of each line.
  2234. \let\par=\lisppar
  2235. \def\Eformat{\endgroup\afterenvbreak}
  2236. \parskip=0pt \parindent=0pt
  2237. \obeyspaces \obeylines
  2238. \def\next##1{}\next}
  2239. % @flushleft and @flushright
  2240. \def\flushleft{%
  2241. \begingroup\inENV %This group ends at the end of the @format body
  2242. \aboveenvbreak
  2243. % Make spaces be word-separators rather than space tokens.
  2244. \sepspaces %
  2245. % The following causes blank lines not to be ignored
  2246. % by adding a space to the end of each line.
  2247. % This also causes @ to work when the directive name
  2248. % is terminated by end of line.
  2249. \let\par=\lisppar
  2250. \def\Eflushleft{\endgroup\afterenvbreak}%
  2251. \parskip=0pt \parindent=0pt
  2252. \obeyspaces \obeylines
  2253. \def\next##1{}\next}
  2254. \def\flushright{%
  2255. \begingroup\inENV %This group ends at the end of the @format body
  2256. \aboveenvbreak
  2257. % Make spaces be word-separators rather than space tokens.
  2258. \sepspaces %
  2259. % The following causes blank lines not to be ignored
  2260. % by adding a space to the end of each line.
  2261. % This also causes @ to work when the directive name
  2262. % is terminated by end of line.
  2263. \let\par=\lisppar
  2264. \def\Eflushright{\endgroup\afterenvbreak}%
  2265. \parskip=0pt \parindent=0pt
  2266. \advance \leftskip by 0pt plus 1fill
  2267. \obeyspaces \obeylines
  2268. \def\next##1{}\next}
  2269. % @quotation - narrow the margins.
  2270. \def\quotation{%
  2271. \begingroup\inENV %This group ends at the end of the @quotation body
  2272. {\parskip=0pt  % because we will skip by \parskip too, later
  2273. \aboveenvbreak}%
  2274. \singlespace
  2275. \parindent=0pt
  2276. \def\Equotation{\par\endgroup\afterenvbreak}%
  2277. % @cartouche defines \nonarrowing to inhibit narrowing
  2278. % at next level down.
  2279. \ifx\nonarrowing\relax
  2280. \advance \leftskip by \lispnarrowing
  2281. \advance \rightskip by \lispnarrowing
  2282. \exdentamount=\lispnarrowing
  2283. \let\nonarrowing=\relax
  2284. \message{defuns,}
  2285. % Define formatter for defuns
  2286. % First, allow user to change definition object font (\df) internally
  2287. \def\setdeffont #1 {\csname DEF#1\endcsname}
  2288. \newskip\defbodyindent \defbodyindent=.4in
  2289. \newskip\defargsindent \defargsindent=50pt
  2290. \newskip\deftypemargin \deftypemargin=12pt
  2291. \newskip\deflastargmargin \deflastargmargin=18pt
  2292. \newcount\parencount
  2293. % define \functionparens, which makes ( and ) and & do special things.
  2294. % \functionparens affects the group it is contained in.
  2295. \def\activeparens{%
  2296. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  2297. \catcode`\[=\active \catcode`\]=\active}
  2298. % Make control sequences which act like normal parenthesis chars.
  2299. \let\lparen = ( \let\rparen = )
  2300. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  2301. % Be sure that we always have a definition for `(', etc.  For example,
  2302. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  2303. % so TeX would otherwise complain about undefined control sequence.
  2304. \global\let(=\lparen \global\let)=\rparen
  2305. \global\let[=\lbrack \global\let]=\rbrack
  2306. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  2307. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  2308. % Definitions of (, ) and & used in args for functions.
  2309. % This is the definition of ( outside of all parentheses.
  2310. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  2311. \global\advance\parencount by 1 }
  2312. % This is the definition of ( when already inside a level of parens.
  2313. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  2314. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  2315. % also in that case restore the outer-level definition of (.
  2316. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  2317. \global\advance \parencount by -1 }
  2318. % If we encounter &foo, then turn on ()-hacking afterwards
  2319. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  2320. \gdef\normalparens{\boldbrax\let&=\ampnr}
  2321. } % End of definition inside \activeparens
  2322. %% These parens (in \boldbrax) actually are a little bolder than the
  2323. %% contained text.  This is especially needed for [ and ]
  2324. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  2325. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  2326. % First, defname, which formats the header line itself.
  2327. % #1 should be the function name.
  2328. % #2 should be the type of definition, such as "Function".
  2329. \def\defname #1#2{%
  2330. % Get the values of \leftskip and \rightskip as they were
  2331. % outside the @def...
  2332. \dimen2=\leftskip
  2333. \advance\dimen2 by -\defbodyindent
  2334. \dimen3=\rightskip
  2335. \advance\dimen3 by -\defbodyindent
  2336. \noindent        %
  2337. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  2338. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  2339. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  2340. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  2341. % Now output arg 2 ("Function" or some such)
  2342. % ending at \deftypemargin from the right margin,
  2343. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  2344. {% Adjust \hsize to exclude the ambient margins,
  2345. % so that \rightline will obey them.
  2346. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  2347. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  2348. % Make all lines underfull and no complaints:
  2349. \tolerance=10000 \hbadness=10000    
  2350. \advance\leftskip by -\defbodyindent
  2351. \exdentamount=\defbodyindent
  2352. {\df #1}\enskip        % Generate function name
  2353. % Actually process the body of a definition
  2354. % #1 should be the terminating control sequence, such as \Edefun.
  2355. % #2 should be the "another name" control sequence, such as \defunx.
  2356. % #3 should be the control sequence that actually processes the header,
  2357. %    such as \defunheader.
  2358. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2359. \medbreak %
  2360. % Define the end token that this defining construct specifies
  2361. % so that it will exit this group.
  2362. \def#1{\endgraf\endgroup\medbreak}%
  2363. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  2364. \parindent=0in
  2365. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2366. \exdentamount=\defbodyindent
  2367. \begingroup %
  2368. \catcode 61=\active %
  2369. \obeylines\activeparens\spacesplit#3}
  2370. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  2371. \medbreak %
  2372. % Define the end token that this defining construct specifies
  2373. % so that it will exit this group.
  2374. \def#1{\endgraf\endgroup\medbreak}%
  2375. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  2376. \parindent=0in
  2377. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2378. \exdentamount=\defbodyindent
  2379. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  2380. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  2381. \medbreak %
  2382. % Define the end token that this defining construct specifies
  2383. % so that it will exit this group.
  2384. \def#1{\endgraf\endgroup\medbreak}%
  2385. \def#2##1 ##2 {\def#4{##1}%
  2386. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  2387. \parindent=0in
  2388. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2389. \exdentamount=\defbodyindent
  2390. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  2391. % These parsing functions are similar to the preceding ones
  2392. % except that they do not make parens into active characters.
  2393. % These are used for "variables" since they have no arguments.
  2394. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2395. \medbreak %
  2396. % Define the end token that this defining construct specifies
  2397. % so that it will exit this group.
  2398. \def#1{\endgraf\endgroup\medbreak}%
  2399. \def#2{\begingroup\obeylines\spacesplit#3}%
  2400. \parindent=0in
  2401. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2402. \exdentamount=\defbodyindent
  2403. \begingroup %
  2404. \catcode 61=\active %
  2405. \obeylines\spacesplit#3}
  2406. \def\defvrparsebody #1#2#3#4 {\begingroup\inENV %
  2407. \medbreak %
  2408. % Define the end token that this defining construct specifies
  2409. % so that it will exit this group.
  2410. \def#1{\endgraf\endgroup\medbreak}%
  2411. \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2412. \parindent=0in
  2413. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2414. \exdentamount=\defbodyindent
  2415. \begingroup\obeylines\spacesplit{#3{#4}}}
  2416. % This seems to work right in all cases.
  2417. \let\deftpparsebody=\defvrparsebody
  2418. % This fails to work.  When given `@deftp {Data Type} foo_t',
  2419. % it thinks the type name is just `f'.
  2420. %%% This is the same as all the others except for the last line.  We need
  2421. %%% to parse the arguments differently for @deftp, since the ``attributes''
  2422. %%% there are optional.
  2423. %%\def\deftpparsebody #1#2#3#4 {\begingroup\inENV %
  2424. %%\medbreak %
  2425. %%% Define the end token that this defining construct specifies
  2426. %%% so that it will exit this group.
  2427. %%\def#1{\endgraf\endgroup\medbreak}%
  2428. %%\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2429. %%\parindent=0in
  2430. %%\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2431. %%\exdentamount=\defbodyindent
  2432. %%\begingroup\obeylines\parsetpheaderline{#3{#4}}}
  2433. %%{\obeylines %
  2434. %%  % Parse the type name and any attributes (field names, etc.).
  2435. %%  % #1 is the beginning of the macro call that will produce the output,
  2436. %%  %   i.e., \deftpheader{CLASS}; this is passed from \deftpparsebody.
  2437. %%  % #2 is the type name, e.g., `struct termios'.
  2438. %%  % #3 is the (possibly empty) attribute list.
  2439. %%  % 
  2440. %%  \gdef\parsetpheaderline#1#2#3^^M{%
  2441. %%    \endgroup % Started in \deftpparsebody.
  2442. %%    %
  2443. %%    % If the attribute list is in fact empty, there will be no space after
  2444. %%    % #2; so we can't put a space in our TeX parameter list.  But if it
  2445. %%    % isn't empty, then #3 will begin with an unwanted space.
  2446. %%    \def\theargs{\ignorespaces #3}%
  2447. %%    %
  2448. %%    % Call the macro to produce the output.
  2449. %%    #1{#2}\theargs %
  2450. %%  }%
  2451. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  2452. \medbreak %
  2453. % Define the end token that this defining construct specifies
  2454. % so that it will exit this group.
  2455. \def#1{\endgraf\endgroup\medbreak}%
  2456. \def#2##1 ##2 {\def#4{##1}%
  2457. \begingroup\obeylines\spacesplit{#3{##2}}}%
  2458. \parindent=0in
  2459. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2460. \exdentamount=\defbodyindent
  2461. \begingroup\obeylines\spacesplit{#3{#5}}}
  2462. % Split up #2 at the first space token.
  2463. % call #1 with two arguments:
  2464. %  the first is all of #2 before the space token,
  2465. %  the second is all of #2 after that space token.
  2466. % If #2 contains no space token, all of it is passed as the first arg
  2467. % and the second is passed as empty.
  2468. {\obeylines
  2469. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  2470. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  2471. \ifx\relax #3%
  2472. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  2473. % So much for the things common to all kinds of definitions.
  2474. % Define @defun.
  2475. % First, define the processing that is wanted for arguments of \defun
  2476. % Use this to expand the args and terminate the paragraph they make up
  2477. \def\defunargs #1{\functionparens \sl
  2478. % Expand, preventing hyphenation at `-' chars.
  2479. % Note that groups don't affect changes in \hyphenchar.
  2480. \hyphenchar\tensl=0
  2481. \hyphenchar\tensl=45
  2482. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  2483. \interlinepenalty=10000
  2484. \advance\rightskip by 0pt plus 1fil
  2485. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2486. \def\deftypefunargs #1{%
  2487. % Expand, preventing hyphenation at `-' chars.
  2488. % Note that groups don't affect changes in \hyphenchar.
  2489. \functionparens
  2490. \code{#1}%
  2491. \interlinepenalty=10000
  2492. \advance\rightskip by 0pt plus 1fil
  2493. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2494. % Do complete processing of one @defun or @defunx line already parsed.
  2495. % @deffn Command forward-char nchars
  2496. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2497. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2498. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2499. \catcode 61=\other % Turn off change made in \defparsebody
  2500. % @defun == @deffn Function
  2501. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2502. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2503. \begingroup\defname {#1}{Function}%
  2504. \defunargs {#2}\endgroup %
  2505. \catcode 61=\other % Turn off change made in \defparsebody
  2506. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  2507. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  2508. % #1 is the data type.  #2 is the name and args.
  2509. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  2510. % #1 is the data type, #2 the name, #3 the args.
  2511. \def\deftypefunheaderx #1#2 #3\relax{%
  2512. \doind {fn}{\code{#2}}% Make entry in function index
  2513. \begingroup\defname {\code{#1} #2}{Function}%
  2514. \deftypefunargs {#3}\endgroup %
  2515. \catcode 61=\other % Turn off change made in \defparsebody
  2516. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  2517. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  2518. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  2519. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  2520. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  2521. \def\deftypefnheaderx #1#2#3 #4\relax{%
  2522. \doind {fn}{\code{#3}}% Make entry in function index
  2523. \begingroup\defname {\code{#2} #3}{#1}%
  2524. \deftypefunargs {#4}\endgroup %
  2525. \catcode 61=\other % Turn off change made in \defparsebody
  2526. % @defmac == @deffn Macro
  2527. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2528. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2529. \begingroup\defname {#1}{Macro}%
  2530. \defunargs {#2}\endgroup %
  2531. \catcode 61=\other % Turn off change made in \defparsebody
  2532. % @defspec == @deffn Special Form
  2533. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2534. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2535. \begingroup\defname {#1}{Special Form}%
  2536. \defunargs {#2}\endgroup %
  2537. \catcode 61=\other % Turn off change made in \defparsebody
  2538. % This definition is run if you use @defunx
  2539. % anywhere other than immediately after a @defun or @defunx.
  2540. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2541. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2542. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2543. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2544. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  2545. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  2546. % @defmethod, and so on
  2547. % @defop {Funny Method} foo-class frobnicate argument
  2548. \def\defop #1 {\def\defoptype{#1}%
  2549. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2550. \def\defopheader #1#2#3{%
  2551. \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2552. \begingroup\defname {#2}{\defoptype{} on #1}%
  2553. \defunargs {#3}\endgroup %
  2554. % @defmethod == @defop Method
  2555. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2556. \def\defmethodheader #1#2#3{%
  2557. \dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2558. \begingroup\defname {#2}{Method on #1}%
  2559. \defunargs {#3}\endgroup %
  2560. % @defcv {Class Option} foo-class foo-flag
  2561. \def\defcv #1 {\def\defcvtype{#1}%
  2562. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2563. \def\defcvarheader #1#2#3{%
  2564. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2565. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2566. \defvarargs {#3}\endgroup %
  2567. % @defivar == @defcv {Instance Variable}
  2568. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  2569. \def\defivarheader #1#2#3{%
  2570. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2571. \begingroup\defname {#2}{Instance Variable of #1}%
  2572. \defvarargs {#3}\endgroup %
  2573. % These definitions are run if you use @defmethodx, etc.,
  2574. % anywhere other than immediately after a @defmethod, etc.
  2575. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2576. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2577. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2578. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2579. % Now @defvar
  2580. % First, define the processing that is wanted for arguments of @defvar.
  2581. % This is actually simple: just print them in roman.
  2582. % This must expand the args and terminate the paragraph they make up
  2583. \def\defvarargs #1{\normalparens #1%
  2584. \interlinepenalty=10000
  2585. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2586. % @defvr Counter foo-count
  2587. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  2588. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2589. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2590. % @defvar == @defvr Variable
  2591. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  2592. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2593. \begingroup\defname {#1}{Variable}%
  2594. \defvarargs {#2}\endgroup %
  2595. % @defopt == @defvr {User Option}
  2596. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  2597. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2598. \begingroup\defname {#1}{User Option}%
  2599. \defvarargs {#2}\endgroup %
  2600. % @deftypevar int foobar
  2601. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  2602. % #1 is the data type.  #2 is the name.
  2603. \def\deftypevarheader #1#2{%
  2604. \doind {vr}{\code{#2}}% Make entry in variables index
  2605. \begingroup\defname {\code{#1} #2}{Variable}%
  2606. \interlinepenalty=10000
  2607. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2608. \endgroup}
  2609. % @deftypevr {Global Flag} int enable
  2610. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  2611. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  2612. \begingroup\defname {\code{#2} #3}{#1}
  2613. \interlinepenalty=10000
  2614. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2615. \endgroup}
  2616. % This definition is run if you use @defvarx
  2617. % anywhere other than immediately after a @defvar or @defvarx.
  2618. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2619. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2620. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2621. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  2622. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  2623. % Now define @deftp
  2624. % Args are printed in bold, a slight difference from @defvar.
  2625. \def\deftpargs #1{\bf \defvarargs{#1}}
  2626. % @deftp Class window height width ...
  2627. \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
  2628. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2629. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2630. % This definition is run if you use @deftpx, etc
  2631. % anywhere other than immediately after a @deftp, etc.
  2632. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2633. \message{cross reference,}
  2634. % Define cross-reference macros
  2635. \newwrite \auxfile
  2636. \newif\ifhavexrefs  % True if xref values are known.
  2637. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2638. % \setref{foo} defines a cross-reference point named foo.
  2639. \def\setref#1{%
  2640. %\dosetq{#1-title}{Ytitle}%
  2641. \dosetq{#1-pg}{Ypagenumber}%
  2642. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2643. \def\unnumbsetref#1{%
  2644. %\dosetq{#1-title}{Ytitle}%
  2645. \dosetq{#1-pg}{Ypagenumber}%
  2646. \dosetq{#1-snt}{Ynothing}}
  2647. \def\appendixsetref#1{%
  2648. %\dosetq{#1-title}{Ytitle}%
  2649. \dosetq{#1-pg}{Ypagenumber}%
  2650. \dosetq{#1-snt}{Yappendixletterandtype}}
  2651. % \xref, \pxref, and \ref generate cross-references to specified points.
  2652. % For \xrefX, #1 is the node name, #2 the name of the Info
  2653. % cross-reference, #3 the printed node name, #4 the name of the Info
  2654. % file, #5 the name of the printed manual.  All but the node name can be
  2655. % omitted.
  2656. \def\pxref#1{see \xrefX[#1,,,,,,,]}
  2657. \def\xref#1{See \xrefX[#1,,,,,,,]}
  2658. \def\ref#1{\xrefX[#1,,,,,,,]}
  2659. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
  2660. \def\printedmanual{\ignorespaces #5}%
  2661. \def\printednodename{\ignorespaces #3}%
  2662. \setbox1=\hbox{\printedmanual}%
  2663. \setbox0=\hbox{\printednodename}%
  2664. \ifdim \wd0=0pt%
  2665. \def\printednodename{\ignorespaces #1}%
  2666. %%% Uncommment the following line to make the actual chapter or section title
  2667. %%% appear inside the square brackets.
  2668. %\def\printednodename{#1-title}%
  2669. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does
  2670. % not insert empty discretionaries after hyphens, which means that it
  2671. % will not find a line break at a hyphen in a node names.  Since some
  2672. % manuals are best written with fairly long node names, containing
  2673. % hyphens, this is a loss.  Therefore, we simply give the text of
  2674. % the node name again, so it is as if TeX is seeing it for the first
  2675. % time.
  2676. \ifdim \wd1>0pt
  2677. section ``\printednodename'' in \cite{\printedmanual}%
  2678. \else%
  2679. \turnoffactive%
  2680. \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}%
  2681. \endgroup}
  2682. % \dosetq is the interface for calls from other macros
  2683. % Use \turnoffactive so that punctuation chars such as underscore
  2684. % work in node names.
  2685. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  2686. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2687. \next}}
  2688. % \internalsetq {foo}{page} expands into
  2689. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2690. % When the aux file is read, ' is the escape character
  2691. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2692. % Things to be expanded by \internalsetq
  2693. \def\Ypagenumber{\folio}
  2694. \def\Ytitle{\thischapter}
  2695. \def\Ynothing{}
  2696. \def\Ysectionnumberandtype{%
  2697. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  2698. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  2699. \else \ifnum \subsubsecno=0 %
  2700. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  2701. \else %
  2702. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2703. \fi \fi \fi }
  2704. \def\Yappendixletterandtype{%
  2705. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}%
  2706. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  2707. \else \ifnum \subsubsecno=0 %
  2708. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2709. \else %
  2710. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2711. \fi \fi \fi }
  2712. \gdef\xreftie{'tie}
  2713. % Use TeX 3.0's \inputlineno to get the line number, for better error
  2714. % messages, but if we're using an old version of TeX, don't do anything.
  2715. \ifx\inputlineno\thisisundefined
  2716.   \let\linenumber = \empty % Non-3.0.
  2717. \else
  2718.   \def\linenumber{\the\inputlineno:\space}
  2719. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2720. % If its value is nonempty, SUFFIX is output afterward.
  2721. \def\refx#1#2{%
  2722.   \expandafter\ifx\csname X#1\endcsname\relax
  2723.     % If not defined, say something at least.
  2724.     $\langle$un\-de\-fined$\rangle$%
  2725.     \ifhavexrefs
  2726.       \message{\linenumber Undefined cross reference `#1'.}%
  2727.     \else
  2728.       \ifwarnedxrefs\else
  2729.         \global\warnedxrefstrue
  2730.         \message{Cross reference values unknown; you must run TeX again.}%
  2731.       \fi
  2732.     \fi
  2733.   \else
  2734.     % It's defined, so just use it.
  2735.     \csname X#1\endcsname
  2736.   \fi
  2737.   #2% Output the suffix in any case.
  2738. % Read the last existing aux file, if any.  No error if none exists.
  2739. % This is the macro invoked by entries in the aux file.
  2740. \def\xrdef #1#2{
  2741. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2742. \def\readauxfile{%
  2743. \begingroup
  2744. \catcode `\^^@=\other
  2745. \catcode `\
  2746. =\other
  2747. \catcode `\
  2748. =\other
  2749. \catcode `\^^C=\other
  2750. \catcode `\^^D=\other
  2751. \catcode `\^^E=\other
  2752. \catcode `\^^F=\other
  2753. \catcode `\^^G=\other
  2754. \catcode `\^^H=\other
  2755. \catcode `\
  2756. =\other
  2757. \catcode `\^^L=\other
  2758. \catcode `\
  2759. =\other
  2760. \catcode `\
  2761. =\other
  2762. \catcode `\
  2763. =\other
  2764. \catcode `\
  2765. =\other
  2766. \catcode `\
  2767. =\other
  2768. \catcode `\
  2769. =\other
  2770. \catcode `\
  2771. =\other
  2772. \catcode `\
  2773. =\other
  2774. \catcode `\
  2775. =\other
  2776. \catcode `\
  2777. =\other
  2778. \catcode `\
  2779. =\other
  2780. \catcode `\
  2781. =\other
  2782. \catcode 26=\other
  2783. \catcode `\^^[=\other
  2784. \catcode `\^^\=\other
  2785. \catcode `\^^]=\other
  2786. \catcode `\^^^=\other
  2787. \catcode `\^^_=\other
  2788. \catcode `\@=\other
  2789. \catcode `\^=\other
  2790. \catcode `\~=\other
  2791. \catcode `\[=\other
  2792. \catcode `\]=\other
  2793. \catcode`\"=\other
  2794. \catcode`\_=\other
  2795. \catcode`\|=\other
  2796. \catcode`\<=\other
  2797. \catcode`\>=\other
  2798. \catcode `\$=\other
  2799. \catcode `\#=\other
  2800. \catcode `\&=\other
  2801. % `\+ does not work, so use 43.
  2802. \catcode 43=\other
  2803. % the aux file uses ' as the escape.
  2804. % Turn off \ as an escape so we do not lose on
  2805. % entries which were dumped with control sequences in their names.
  2806. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  2807. % Reference to such entries still does not work the way one would wish,
  2808. % but at least they do not bomb out when the aux file is read in.
  2809. \catcode `\{=1 \catcode `\}=2
  2810. \catcode `\%=\other
  2811. \catcode `\'=0
  2812. \catcode `\\=\other
  2813. \openin 1 \jobname.aux
  2814. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  2815. % Open the new aux file.  Tex will close it automatically at exit.
  2816. \openout \auxfile=\jobname.aux
  2817. \endgroup}
  2818. % Footnotes.
  2819. \newcount \footnoteno
  2820. % The trailing space in the following definition for supereject is
  2821. % vital for proper filling; pages come out unaligned when you do a
  2822. % pagealignmacro call if that space before the closing brace is
  2823. % removed.
  2824. \def\supereject{\par\penalty -20000\footnoteno =0 }
  2825. % @footnotestyle is meaningful for info output only..
  2826. \let\footnotestyle=\comment
  2827. \let\ptexfootnote=\footnote
  2828. {\catcode `\@=11
  2829. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  2830. \unskip
  2831. \edef\thisfootno{$^{\the\footnoteno}$}%
  2832. \let\@sf\empty
  2833. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  2834. \thisfootno\@sf \footnotezzz{#1}}
  2835. % \parsearg\footnotezzz}
  2836. \long\gdef\footnotezzz #1{\insert\footins{
  2837. \interlinepenalty\interfootnotelinepenalty
  2838. \splittopskip\ht\strutbox % top baseline for broken footnotes
  2839. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  2840. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  2841. \footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}}
  2842. }%end \catcode `\@=11
  2843. % Set the baselineskip to #1, and the lineskip and strut size
  2844. % correspondingly.  There is no deep meaning behind these magic numbers
  2845. % used as factors; they just match (closely enough) what Knuth defined.
  2846. \def\lineskipfactor{.1}
  2847. \def\strutheightpercent{.71}
  2848. \def\strutdepthpercent{.29}
  2849. \def\setleading#1{%
  2850.   \baselineskip = #1\relax
  2851.   \normalbaselineskip = \baselineskip
  2852.   \lineskip = \lineskipfactor\baselineskip
  2853.   \setbox\strutbox =\hbox{%
  2854.     \vrule width0pt height\strutheightpercent\baselineskip
  2855.                     depth \strutdepthpercent \baselineskip
  2856. % @| inserts a changebar to the left of the current line.  It should
  2857. % surround any changed text.  This approach does *not* work if the
  2858. % change spans more than two lines of output.  To handle that, we would
  2859. % have adopt a much more difficult approach (putting marks into the main
  2860. % vertical list for the beginning and end of each change).
  2861. \def\|{%
  2862.   % \vadjust can only be used in horizontal mode.
  2863.   \leavevmode
  2864.   % Append this vertical mode material after the current line in the output.
  2865.   \vadjust{%
  2866.     % We want to insert a rule with the height and depth of the current
  2867.     % leading; that is exactly what \strutbox is supposed to record.
  2868.     \vskip-\baselineskip
  2869.     %
  2870.     % \vadjust-items are inserted at the left edge of the type.  So
  2871.     % the \llap here moves out into the left-hand margin.
  2872.     \llap{%
  2873.       %
  2874.       % For a thicker or thinner bar, change the `1pt'.
  2875.       \vrule height\baselineskip width1pt
  2876.       %
  2877.       % This is the space between the bar and the text.
  2878.       \hskip 12pt
  2879.     }%
  2880. % For a final copy, take out the rectangles
  2881. % that mark overfull boxes (in case you have decided
  2882. % that the text looks ok even though it passes the margin).
  2883. \def\finalout{\overfullrule=0pt}
  2884. % End of control word definitions.
  2885. \message{and turning on texinfo input format.}
  2886. \def\openindices{%
  2887.    \newindex{cp}%
  2888.    \newcodeindex{fn}%
  2889.    \newcodeindex{vr}%
  2890.    \newcodeindex{tp}%
  2891.    \newcodeindex{ky}%
  2892.    \newcodeindex{pg}%
  2893. % Set some numeric style parameters, for 8.5 x 11 format.
  2894. %\hsize = 6.5in
  2895. \newdimen\defaultparindent \defaultparindent = 15pt
  2896. \parindent = \defaultparindent
  2897. \parskip 18pt plus 1pt
  2898. \setleading{15pt}
  2899. \advance\topskip by 1.2cm
  2900. % Prevent underfull vbox error messages.
  2901. \vbadness=10000
  2902. % Following George Bush, just get rid of widows and orphans.
  2903. \widowpenalty=10000
  2904. \clubpenalty=10000
  2905. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  2906. % using an old version of TeX, don't do anything.  We want the amount of
  2907. % stretch added to depend on the line length, hence the dependence on
  2908. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  2909. \ifx\emergencystretch\thisisundefined \else
  2910.   \emergencystretch = \hsize
  2911.   \divide\emergencystretch by 45
  2912. % Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
  2913. \def\smallbook{
  2914. % These values for secheadingskip and subsecheadingskip are
  2915. % experiments.  RJC 7 Aug 1992
  2916. \global\secheadingskip = 17pt plus 6pt minus 3pt
  2917. \global\subsecheadingskip = 14pt plus 6pt minus 3pt
  2918. \global\lispnarrowing = 0.3in
  2919. \setleading{12pt}
  2920. \advance\topskip by -1cm
  2921. \global\parskip 3pt plus 1pt
  2922. \global\hsize = 5in
  2923. \global\vsize=7.5in
  2924. \global\tolerance=700
  2925. \global\hfuzz=1pt
  2926. \global\contentsrightmargin=0pt
  2927. \global\pagewidth=\hsize
  2928. \global\pageheight=\vsize
  2929. \global\let\smalllisp=\smalllispx
  2930. \global\let\smallexample=\smalllispx
  2931. \global\def\Esmallexample{\Esmalllisp}
  2932. % Use @afourpaper to print on European A4 paper.
  2933. \def\afourpaper{
  2934. \global\tolerance=700
  2935. \global\hfuzz=1pt
  2936. \setleading{12pt}
  2937. \global\parskip 15pt plus 1pt
  2938. \global\vsize= 53\baselineskip
  2939. \advance\vsize by \topskip
  2940. %\global\hsize=   5.85in     % A4 wide 10pt
  2941. \global\hsize=  6.5in
  2942. \global\outerhsize=\hsize
  2943. \global\advance\outerhsize by 0.5in
  2944. \global\outervsize=\vsize
  2945. \global\advance\outervsize by 0.6in
  2946. \global\pagewidth=\hsize
  2947. \global\pageheight=\vsize
  2948. % Define macros to output various characters with catcode for normal text.
  2949. \catcode`\"=\other
  2950. \catcode`\~=\other
  2951. \catcode`\^=\other
  2952. \catcode`\_=\other
  2953. \catcode`\|=\other
  2954. \catcode`\<=\other
  2955. \catcode`\>=\other
  2956. \catcode`\+=\other
  2957. \def\normaldoublequote{"}
  2958. \def\normaltilde{~}
  2959. \def\normalcaret{^}
  2960. \def\normalunderscore{_}
  2961. \def\normalverticalbar{|}
  2962. \def\normalless{<}
  2963. \def\normalgreater{>}
  2964. \def\normalplus{+}
  2965. % This macro is used to make a character print one way in ttfont
  2966. % where it can probably just be output, and another way in other fonts,
  2967. % where something hairier probably needs to be done.
  2968. % #1 is what to print if we are indeed using \tt; #2 is what to print
  2969. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  2970. % interword stretch (and shrink), and it is reasonable to expect all
  2971. % typewriter fonts to have this, we can check that font parameter.
  2972. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  2973. % Turn off all special characters except @
  2974. % (and those which the user can use as if they were ordinary).
  2975. % Most of these we simply print from the \tt font, but for some, we can
  2976. % use math or other variants that look better in normal text.
  2977. \catcode`\"=\active
  2978. \def\activedoublequote{{\tt \char '042}}
  2979. \let"=\activedoublequote
  2980. \catcode`\~=\active
  2981. \def~{{\tt \char '176}}
  2982. \chardef\hat=`\^
  2983. \catcode`\^=\active
  2984. \def^{{\tt \hat}}
  2985. \catcode`\_=\active
  2986. \def_{\ifusingtt\normalunderscore\_}
  2987. % Subroutine for the previous macro.
  2988. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  2989. % \lvvmode is equivalent in function to \leavevmode.
  2990. % Using \leavevmode runs into trouble when written out to
  2991. % an index file due to the expansion of \leavevmode into ``\unhbox
  2992. % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
  2993. % magic tricks with @.
  2994. \def\lvvmode{\vbox to 0pt{}}
  2995. \catcode`\|=\active
  2996. \def|{{\tt \char '174}}
  2997. \chardef \less=`\<
  2998. \catcode`\<=\active
  2999. \def<{{\tt \less}}
  3000. \chardef \gtr=`\>
  3001. \catcode`\>=\active
  3002. \def>{{\tt \gtr}}
  3003. \catcode`\+=\active
  3004. \def+{{\tt \char 43}}
  3005. %\catcode 27=\active
  3006. %\def^^[{$\diamondsuit$}
  3007. % Used sometimes to turn off (effectively) the active characters
  3008. % even after parsing them.
  3009. \def\turnoffactive{\let"=\normaldoublequote
  3010. \let~=\normaltilde
  3011. \let^=\normalcaret
  3012. \let_=\normalunderscore
  3013. \let|=\normalverticalbar
  3014. \let<=\normalless
  3015. \let>=\normalgreater
  3016. \let+=\normalplus}
  3017. % Set up an active definition for =, but don't enable it most of the time.
  3018. {\catcode`\==\active
  3019. \global\def={{\tt \char 61}}}
  3020. \catcode`\@=0
  3021. % \rawbackslashxx output one backslash character in current font
  3022. \global\chardef\rawbackslashxx=`\\
  3023. %{\catcode`\\=\other
  3024. %@gdef@rawbackslashxx{\}}
  3025. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  3026. {\catcode`\\=\active
  3027. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  3028. % \normalbackslash outputs one backslash in fixed width font.
  3029. \def\normalbackslash{{\tt\rawbackslashxx}}
  3030. % Say @foo, not \foo, in error messages.
  3031. \escapechar=`\@
  3032. % \catcode 17=0   % Define control-q
  3033. \catcode`\\=\active
  3034. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  3035. % That is what \eatinput is for; after that, the `\' should revert to printing 
  3036. % a backslash.
  3037. @gdef@eatinput input texinfo{@fixbackslash}
  3038. @global@let\ = @eatinput
  3039. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  3040. % the first `\{ in the file would cause an error. This macro tries to fix 
  3041. % that, assuming it is called before the first `\' could plausibly occur.
  3042. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  3043. %% These look ok in all fonts, so just make them not special.  The @rm below
  3044. %% makes sure that the current font starts out as the newly loaded cmr10
  3045. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  3046. @textfonts
  3047. @c Local variables:
  3048. @c page-delimiter: "^\\\\message"
  3049. @c End:
  3050.